newbie - Scoping question

Fredrik Lundh fredrik at
Mon Sep 17 19:13:56 CEST 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:


<!-- (the eff-bot guide to) the python standard library:

More information about the Python-list mailing list