"import X" and "from X import y" produce different results, Why?
Robin Thomas
robin.thomas at starmedia.net
Thu Mar 1 02:03:53 EST 2001
At 06:46 AM 3/1/01 +0000, Parzival Herzog wrote:
>So, apparently the imported X is a copy of xx.X, not the same object by
>another name.
>Can anyone explain this result? Is this result justified by a Python
>language specifcation?
You "re-bound" the local name X to 99. When you did that, the object
previously bound to the local name X -- 35, which was bound to X by "from
xx import X" -- was unbound. A clearer example without the import to
confuse you:
X = 35
print X
X = 99
print X
--
Robin Thomas
Engineering
StarMedia Network, Inc.
robin.thomas at starmedia.net
More information about the Python-list
mailing list