Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > keyword that stops further processing of a Python script

Reply
Thread Tools

keyword that stops further processing of a Python script

 
 
Avi Kak
Guest
Posts: n/a
 
      02-17-2004


Hello:

Does Python provide a token like Perl's __END__
that would mark the logical end of a Python script
which could occur before the actual end of the file.

I have found Perl's __END__ token to be very useful
for debugging scripts. So I was wondering if
Python provided a similar facility.

Avi Kak
 
Reply With Quote
 
 
 
 
Dave Benjamin
Guest
Posts: n/a
 
      02-17-2004
In article <>, Avi Kak wrote:
>
> Does Python provide a token like Perl's __END__
> that would mark the logical end of a Python script
> which could occur before the actual end of the file.
>
> I have found Perl's __END__ token to be very useful
> for debugging scripts. So I was wondering if
> Python provided a similar facility.


I think it's denoted by an endless expanse of significant whitespace.
Har, har. Sorry, couldn't resist.

--
..:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:.
: d r i n k i n g l i f e o u t o f t h e c o n t a i n e r :
 
Reply With Quote
 
 
 
 
Peter Otten
Guest
Posts: n/a
 
      02-17-2004
Avi Kak wrote:

> Does Python provide a token like Perl's __END__
> that would mark the logical end of a Python script
> which could occur before the actual end of the file.
>
> I have found Perl's __END__ token to be very useful
> for debugging scripts. So I was wondering if
> Python provided a similar facility.


I use sys.exit("debug") which exits from the logical rather than the text
flow. As an alternative you could reserve one kind of docstrings to
neutralize arbitrary chunks of code - e. g. I never use ''' ... '''. Last
not least: every decent editor provides comment/uncomment commands.

Peter
 
Reply With Quote
 
Miki Tebeka
Guest
Posts: n/a
 
      02-17-2004
Hello Avi,

> Does Python provide a token like Perl's __END__
> that would mark the logical end of a Python script
> which could occur before the actual end of the file.

Just place `raise SystemExit' where you want the script to stop.
Another option of to use triple quotes around the end of the file.

HTH.
Miki
 
Reply With Quote
 
Avi Kak
Guest
Posts: n/a
 
      02-17-2004


Hello:

I would like to thank Peter Otten and Miki Tebeka
for posting their replies. I was getting tired of
having to repeatedly comment out and uncomment my
long scripts during their development.

To summarize what Peter and Miki said, the logical
end of a script can be marked either with sys.exit("debug")
or with 'raise SystemExit'. Another option is to
put triple quotes around the part of the script you
don't want to see executed.

In retrospect, all three suggestions --- especially the
one about using triple quotes --- should have been
obvious to me. But that's the way the human brain works.
Sometimes what's seemingly the most obvious is not so
obvious until someone else points out its obviousness.

Avi

On 17 Feb 2004 03:26:28 -0800, (Miki Tebeka)
wrote:

>Hello Avi,
>
>> Does Python provide a token like Perl's __END__
>> that would mark the logical end of a Python script
>> which could occur before the actual end of the file.

>Just place `raise SystemExit' where you want the script to stop.
>Another option of to use triple quotes around the end of the file.
>
>HTH.
>Miki


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Problem with search, postback and further processing jaffarkazi ASP .Net 0 08-01-2008 04:17 PM
RE: keyword checker - keyword.kwlist Hamilton, William Python 4 05-13-2007 06:31 AM
keyword checker - keyword.kwlist tom@finland.com Python 6 05-10-2007 04:53 PM
Stopping further processing with an Exit Sub in the Page_Load Event not working. Jason ASP .Net 2 06-10-2004 01:36 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57