Python end of file marker similar to perl's __END__

Diez B. Roggisch deets at
Wed Aug 1 17:16:16 CEST 2007

beginner wrote:

> On Jul 31, 10:53 pm, beginner <zyzhu2... at> wrote:
>> Hi All,
>> This is just a very simple question about a python trick.
>> In perl, I can write __END__ in a file and the perl interpreter will
>> ignore everything below that line. This is very handy when testing my
>> program. Does python have something similar?
>> Thanks,
>> Geoffrey
> 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.

In emacs, I simply mark that portion of code and do

M-x comment-region

That's it. And I don't think a language should support things __END__ -
commenting is enough. It's unfortunate that Python doesn't support
multi-line-comments though. But as I said, that my Editor can handle for


More information about the Python-list mailing list