keyword that stops further processing of a Python script
kak at purdue.edu
Tue Feb 17 16:08:18 CET 2004
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.
On 17 Feb 2004 03:26:28 -0800, miki.tebeka at zoran.com (Miki Tebeka)
>> 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.
More information about the Python-list