Odd import behavior

Gregory Piñero gregpinero at gmail.com
Thu Feb 1 17:33:50 EST 2007


I didn't realize Python behaved like this.  Is there an FAQ I can read on this?

FILE module1.py:
VAR1='HI'

FILE MAIN.py:
from module1 import *
import module1

print VAR1
print module1.VAR1

VAR1='bye'
print VAR1
print module1.VAR1

And the results are:

>>> HI
HI
bye
HI

It seems to use module1.VAR1 for VAR1 until I assign something to VAR1
in which case they become seperate.

-Greg



More information about the Python-list mailing list