newbie - Scoping question
Fredrik Lundh
fredrik at pythonware.com
Mon Sep 17 13:13:56 EDT 2001
"P Adhia" wrote:
> I'll appreciate if anyone can me clarify my Python scoping rules a
> bit.
scoping has nothing to do with this.
> >>> from test import *
in Python, a variable is a name associated with an object.
the from-import statement creates new names, in the current
module, which points to existing objects from another module.
> >>> x = [1,2,3]
assignment also creates new names in the current module.
the above statement doesn't modify the original "x" object;
it creates a new list, and gives it a name.
> I am confused as to why "x", when not qualified with module name, does
> not refer to "x" in "test", even though I did "from test import *".
if the introductory book you used to learn Python didn't explain
this, ask for a refund ;-)
reading the following articles might help:
http://effbot.org/guides/python-objects.htm
http://effbot.org/guides/import-confusion.htm
</F>
<!-- (the eff-bot guide to) the python standard library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->
More information about the Python-list
mailing list