Message75635
People seem to understand that they can not use variable before
definition. But this dramatically change when they come across nested
functions. They don't understand when variable can be resolved from
outer scope and when can not, e.g:
def outer():
x = 1
def inner1():
print(x)
def inner2():
print(x)
# [... some instructions (maybe a lot) ...]
x = 1
They are always confused why `inner1` works but `inner2` doesn't. |
|
Date |
User |
Action |
Args |
2008-11-08 13:06:52 | robwolfe | set | recipients:
+ robwolfe, georg.brandl, terry.reedy |
2008-11-08 13:06:51 | robwolfe | set | messageid: <1226149611.97.0.574320655579.issue4246@psf.upfronthosting.co.za> |
2008-11-08 13:06:51 | robwolfe | link | issue4246 messages |
2008-11-08 13:06:50 | robwolfe | create | |
|