[ python-Bugs-850110 ] Out of order commands excecution?
SourceForge.net
noreply at sourceforge.net
Thu Nov 27 07:09:29 EST 2003
Bugs item #850110, was opened at 2003-11-27 08:54
Message generated for change (Comment added) made by mwh
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: Closed
>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: 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