import from question

Tobiah toby at tobiah.org
Wed Jan 16 15:14:02 EST 2008


Ben Finney wrote:
> Tobiah <toby at tobiah.org> writes:
> 
>> This is a little surprising. So "from mod import *" really copies
>> all of the scalars into new variables in the local namespace.
> 
> No. Nothing is copied. All the objects (remembering that in Python,
> *everything* is an object) created by the code in module 'mod' are
> given names in the current namespace.

Yeah, copied.  Just as in:

>>> a = 3
>>> b = a
>>> a = 5
>>> b
3
>>>



given b.py:

##########################
thing = 0
##########################

and a.py:

##########################
from b import *
import b

print thing
print b.thing

b.thing = 1
print b.thing
print thing
###########################

0
0
1
0

-- 
Posted via a free Usenet account from http://www.teranews.com




More information about the Python-list mailing list