John Salerno wrote:
[snip..]
>
> Thanks guys. It seems like nested functions were what the authors had in
> mind, so that makes a lot more sense now.
>
> But as far as ifs and loops, is there such a thing as scope in them? For
> example, if I assign a variable within an if statement, is it usable
> anywhere else?

Defining a variable in a loop, or within an 'if block' doesn't change
scope, so the variables are useable in the same way as variables
outside the loop. Obviously if you define them within an if block, they
may *not* be defined, so using them could raise a NameError.

if False:
    test = 'something'
print test

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to