comments inside blocks

Peter Hansen peter at engcorp.com
Thu Jan 2 19:31:17 CET 2003


P_spam_ at draigBrady.com wrote:
> 
> Well it also folds if there is any amount of whitespace
> between the block and the comment. I.E.
> 
> for i in range(10):
>      print i
> 
> #comment nothing to do with for
> def fn():
>      print "fn"

Okay, good point.  Remember though, that this is also valid
Python:

for i in range(10):
    print i

# if we make it to the end, do this
else:
    print 'loop completed normally!'

I'm afraid you probably can't get the behaviour you want without a lot
more logic than the program currently has.  It might be doable, but 
not easy...

-Peter




More information about the Python-list mailing list