Python end of file marker similar to perl's __END__

Neil Cerutti horpner at yahoo.com
Wed Aug 1 12:27:02 EDT 2007


On 2007-08-01, Cameron Laird <claird at lairds.us> wrote:
> In article <slrnfb17m5.224.horpner at FIAD06.norwich.edu>,
> Neil Cerutti  <horpner at yahoo.com> wrote:
>>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.
> 			.
> 			.
> 			.
> I want to re-emphasize the "triple-quote it" tip mentioned
> earlier in this thread.  I think the original questioner
> will find this quite satisfying, if I understand his situ-
> ation at all.
>
> *I* certainly have source code with embedded "junk" 
> commented out as multi-line strings.

I used to do that, but now that I use doctests so much it's
infeasible to comment out arbitrary code that way, since they
can't necessarily nest.

But Diez suggestion is even easier than the if False suggestion I
made.

-- 
Neil Cerutti




More information about the Python-list mailing list