statements and blocks

William Tanksley wtanksle at hawking.armored.net
Sat Jan 29 01:26:11 EST 2000


On 28 Jan 2000 21:13:03 GMT, John Kochmar wrote:
>OK, I haven't seen this in the FAQ (Yeah, I did look ;^), and maybe I 
>just missed it, but someone at the Python conference (sorry, I forget
>which talk) brought up that you couldn't do:

>	print "a"
>	print "b"
>		print "c"
>		print "d"
>		print "e"
>	print "f"

>to visually set off a block of statements.  And ahort of forcing a different 
>scope though a conditional, loop, or some other scope modifier, I haven't 
>been able to create a block of statements in a seperate context.

One way to do that is to use a try: block.  Since many of the cases where
you have a block like that have special entry and exit code, you can
enclose the exit code in a finally: statement.

Oh, and the reason why you won't see any bare-block syntax in Python: that
would make it impossible to detect accidental indentation change.  That,
in turn, would make it harder to select the most virulent
whitespace-eating nanoviruses ;-).

>John

-- 
-William "Billy" Tanksley, in hoc signo hack



More information about the Python-list mailing list