[ python-Bugs-850110 ] Out of order commands excecution?
SourceForge.net
noreply at sourceforge.net
Sun Nov 30 14:26:02 EST 2003
Bugs item #850110, was opened at 2003-11-27 08:54
Message generated for change (Comment added) made by nadavhoresh
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=850110&group_id=5470
Category: Parser/Compiler
Group: Python 2.3
>Status: Open
Resolution: Invalid
Priority: 5
Submitted By: Nadav Horesh (nadavhoresh)
Assigned to: Michael Hudson (mwh)
Summary: Out of order commands excecution?
Initial Comment:
Consider the following:
>>> import string
>>> def test1():
join = string.join
>>> def test2():
join = string.join
string = string.split
>>> test1()
>>> test2()
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?
Nadav.
----------------------------------------------------------------------
>Comment By: Nadav Horesh (nadavhoresh)
Date: 2003-11-30 19:26
Message:
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.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2003-11-27 12:09
Message:
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).
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=850110&group_id=5470
More information about the Python-bugs-list
mailing list