keyword that stops further processing of a Python script

Peter Otten __peter__ at web.de
Tue Feb 17 03:03:31 EST 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



More information about the Python-list mailing list