Python end of file marker similar to perl's __END__

Neil Cerutti horpner at yahoo.com
Wed Aug 1 10:51:34 EDT 2007


On 2007-08-01, beginner <zyzhu2000 at gmail.com> wrote:
> Thanks everyone for responding. It doesn't look like python has
> it. I would definitely miss it. As Steve said, the nice thing
> about __END__ is that things below __END__ do not have to have
> legit syntax. That let me focus on the lines of code I am
> debugging and do not have to worry about some bad syntax down
> the line. This feature is especially handy if I am, saying,
> replacing modoules or changing data structures.

A C-like trick might be helpful while refactoring:

<working code>
if False:
   <non-working code>

You have to indent all the non-working code by one level, but
with a good editor that's a snap.

Python will still parse the following lines (it must be valid
Python syntax), but the resulting parse tree won't be executed.

-- 
Neil Cerutti



More information about the Python-list mailing list