Python end of file marker similar to perl's __END__

Chris Mellon arkanes at gmail.com
Wed Aug 1 11:13:50 EDT 2007


On 8/1/07, beginner <zyzhu2000 at gmail.com> wrote:
> On Jul 31, 10:53 pm, beginner <zyzhu2... at gmail.com> 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.
>

You'll probably find greater gains by embracing the limitation and
using it to help you refactor your code into smaller, more discrete
modules. Many of pythons limitations that beginners complain about are
of this nature.



More information about the Python-list mailing list