statements and blocks
John Mitchell
johnm at magnet.com
Fri Jan 28 18:43:35 EST 2000
On 28 Jan 2000, 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.
I'd say just do the "if 1" think and deal with it:
print "a"
print "b"
if 1:
print "c"
print "d"
print "e"
print "f"
I use this technique a *lot*, but mostly for testing: use "if 0" to take
code out, "if 1" to re-use it. Its also useful as "if 0: xxx else: yyy".
One code change swaps two segments of code.
One talk at the conference ("Python for Scene and Model Description for
Computer Graphics") used too many pushes and pops. I suggested using
tuple- or list-format to make things a little better. Now that I think
about it, it would probably suck. Hmph.
- j
More information about the Python-list
mailing list