Message135380
Consider these two functions:
---
def nok():
a = None
def f():
if a:
a = 1
f()
def ok():
a = None
def f():
if a:
b = 1
f()
---
Function ok() executes fine, but function nok() trigger an exception:
Traceback (most recent call last):
File "pb.py", line 20, in <module>
nok()
File "pb.py", line 7, in nok
f()
File "pb.py", line 5, in f
if a:
UnboundLocalError: local variable 'a' referenced before assignment
There is no reason for this to happen
Regards,
Rodrigo Ventura |
|
Date |
User |
Action |
Args |
2011-05-06 22:53:05 | Rodrigo.Ventura | set | recipients:
+ Rodrigo.Ventura |
2011-05-06 22:53:05 | Rodrigo.Ventura | set | messageid: <1304722385.56.0.574647531565.issue12023@psf.upfronthosting.co.za> |
2011-05-06 22:53:04 | Rodrigo.Ventura | link | issue12023 messages |
2011-05-06 22:53:04 | Rodrigo.Ventura | create | |
|