[Tutor] Question on "import foobar" vs "from foobar import *"

bob gailer bgailer at gmail.com
Sun Jan 10 02:52:37 CET 2010

Eric Pavey wrote:
> I should add (that as I understand it), when you do a 'from foo import 
> blah', or 'from foo import *', this is doing a /copy/ (effectively) of 
> that module's attributes into the current namespace.
Not a copy (which means duplicating the attribute) but a new reference 
to the original attribute. Example
 >>> import sys
 >>> from sys import modules
 >>> sys.modules is modules
 >>> m = dict(sys.modules) # create a copy
 >>> m is modules

Bob Gailer
Chapel Hill NC

More information about the Tutor mailing list