Python scoping

Mikael Olofsson mikael at isy.liu.se
Fri Oct 27 02:33:49 EDT 2000


On 26-Oct-00 Steven D. Majewski wrote:
 >  
 >  On Thu, 26 Oct 2000, William Park wrote:
 >  
 > > 
 > > Good programmers always use indentation, with or without braces.  But, I
 > > personally wouldn't mind "end" statements (ie. endif, endfor, endwhile,
 > > etc.) for situations where blocks are longer than one screen.
 > > 
 >  
 >  I try to keep my blocks and functions short enough to be easily readable,
 >  but yes: there are times when they have to be longer than a page. But 
 >  in those cases, even with a block delimiter, I find I need to use 
 >  additional comments: 'endif' isn't enough because I probably have
 >  multiple if statements, so I need "endif (test-condition)" to match
 >  up with "if (test-condition)". 
 >   I don't know of any programming languages that are quite that verbose,
 >  and I'm not sure I would like it since the shorter one-page cases 
 >  vastly prevail, so I might as well use comments for those exceptional
 >  cases. ( And it's not any harder to use comments with "offside rule" 
 >  block structure than it is with explicit end tokens. ) 

This has been said before on numerous occations:

These delimiters do exist in python. Just do

for a in A:
  whatever
#endfor

The delimiters are very flexible. You may exclude them if you wish, as I
do, and you may spell them in many ways. Examples:

#end
#end for
#end for a
#ende
#slut
#fin
#rof

The interpreter simply disregards them since they do not carry any 
information.

/Mikael

-----------------------------------------------------------------------
E-Mail:  Mikael Olofsson <mikael at isy.liu.se>
WWW:     http://www.dtr.isy.liu.se/dtr/staff/mikael               
Phone:   +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
Date:    27-Oct-00
Time:    08:26:39

         /"\
         \ /     ASCII Ribbon Campaign
          X      Against HTML Mail
         / \

This message was sent by XF-Mail.
-----------------------------------------------------------------------




More information about the Python-list mailing list