Message75614
Your example seem too verbose and diffuse. Perhaps something more
focused on what people do wrong would be more helpful. I presume you
mean something like this -- with or without x=2 before the def.
>>> def f():
print (x)
x = 1
>>> f()
Traceback (most recent call last):
File "<pyshell#31>", line 1, in <module>
f()
File "<pyshell#30>", line 2, in f
print (x)
UnboundLocalError: local variable 'x' referenced before assignment
What are the other ways people get the error. |
|
| Date |
User |
Action |
Args |
| 2008-11-07 20:38:33 | terry.reedy | set | recipients:
+ terry.reedy, georg.brandl, robwolfe |
| 2008-11-07 20:38:33 | terry.reedy | set | messageid: <[email protected]> |
| 2008-11-07 20:38:32 | terry.reedy | link | issue4246 messages |
| 2008-11-07 20:38:32 | terry.reedy | create | |
|