The Difference between Import and From??
Akira Kiyomiya
akira.kiyomiya at autodesk.com
Tue Mar 14 16:30:29 EST 2000
Well, I have a simple question that I cannot wait to ask. So here you go.
It should be simple.
% cat small.py
x = 1
y = [1, 2]
% python
>>> from small import x, y
>>> x = 42
>>> y[0] = 42
>>>
>>> import small
>>> small.x
1 # why? I tought it would be 42?
>>> small.y
[42 ,2] # yeah, I thought so.
I have a feeling that I am confused of how Python imports a file. Maybe
the difference between import and from??
Thanks
Akira
More information about the Python-list
mailing list