Message108306
| Author |
Andreas Hofmeister |
| Recipients |
Andreas Hofmeister |
| Date |
2010年06月21日.19:46:37 |
| SpamBayes Score |
0.007829412 |
| Marked as misclassified |
No |
| Message-id |
<1277149599.18.0.763779339646.issue9049@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Description:
An unexpected UnboundLocalError is produced when assigning a value to a variable inside a nested function. The first assignment to the variable is in the enclosing function.
Example:
def x():
a = False
def y():
print a
a = True
return y
Calling x()() produces an UnboundLocalError on the 'print a' line.
If the 'a = True' line is removed, no error occurs.
Tested with:
- 2.5.1
- 2.6.5
Keywords:
Nested function, UnboundLocalError, variable assignment
Thank you for your attention |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2010年06月21日 19:46:39 | Andreas Hofmeister | set | recipients:
+ Andreas Hofmeister |
| 2010年06月21日 19:46:39 | Andreas Hofmeister | set | messageid: <1277149599.18.0.763779339646.issue9049@psf.upfronthosting.co.za> |
| 2010年06月21日 19:46:37 | Andreas Hofmeister | link | issue9049 messages |
| 2010年06月21日 19:46:37 | Andreas Hofmeister | create |
|