You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/mwhudson'closed_at=<Date2003-12-01.14:31:04.000>created_at=<Date2003-11-27.08:54:21.000>labels= ['interpreter-core', 'invalid']
title='Out of order commands excecution?'updated_at=<Date2003-12-01.14:31:04.000>user='https://bugs.python.org/nadavhoresh'
Traceback (most recent call last):
File "<pyshell#9>", line 1, in -toplevel-
test2()
File "<pyshell#7>", line 2, in test2
join = string.join
UnboundLocalError: local variable 'string' referenced
before assignment
>>>
How the second statement in test2 generates an error in
first one?
I've looked at the FAQ and it is not seems to sesolve the
issue: In test2 "string" becomes a local variable in the
second line, while in the first line (join = string.join)
"string" should point to the (global) string module.
Nadav.
nnorwitz commented on Dec 1, 2003
nnorwitzmannequin
Mannequin
More actions
Logged In: YES
user_id=33168
If a variable is local in a function, it is local throughout
the whole function. It doesn't become local at the first
assignment, but from the beginning of the function. Does
that help?
Well, you reopened the bug, so you're obviously not happy.
What do you want to see changed? The behaviour? No chance.
Better documentation? Feel free to supply a patch (or just
suggest wording and a location, others can do the latex).
nadavhoresh commented on Dec 1, 2003
nadavhoreshmannequin
MannequinAuthor
More actions
Logged In: YES
user_id=75473
I understand that this is just a documentation issue. I
guess that probably the interpreter builds the variables
table before executing the first line of code. But, I afraid
that I am not familiar with the internal of python to raise
such statements.
Activity
nadavhoresh commentedon Nov 27, 2003
Consider the following:
How the second statement in test2 generates an error in
first one?
Nadav.
mwhudson commentedon Nov 27, 2003
Logged In: YES
user_id=6656
Well, that's just how it works. This must be documented
somewhere... see if
http://www.python.org/doc/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python
helps (and maybe the question before).
nadavhoresh commentedon Nov 30, 2003
Logged In: YES
user_id=75473
I've looked at the FAQ and it is not seems to sesolve the
issue: In test2 "string" becomes a local variable in the
second line, while in the first line (join = string.join)
"string" should point to the (global) string module.
Nadav.
nnorwitz commentedon Dec 1, 2003
Logged In: YES
user_id=33168
If a variable is local in a function, it is local throughout
the whole function. It doesn't become local at the first
assignment, but from the beginning of the function. Does
that help?
mwhudson commentedon Dec 1, 2003
Logged In: YES
user_id=6656
Well, you reopened the bug, so you're obviously not happy.
What do you want to see changed? The behaviour? No chance.
Better documentation? Feel free to supply a patch (or just
suggest wording and a location, others can do the latex).
nadavhoresh commentedon Dec 1, 2003
Logged In: YES
user_id=75473
I understand that this is just a documentation issue. I
guess that probably the interpreter builds the variables
table before executing the first line of code. But, I afraid
that I am not familiar with the internal of python to raise
such statements.
Thank you very much for your help
Nadav.