Module trouble [newbie]

Goldfish gregturn at mindspring.com
Fri Feb 23 10:23:54 EST 2007


On Feb 23, 6:44 am, Boris Ozegovic <silovana.vjever... at com.gmail>
wrote:
> Can somebody explaint this to me:
>
> I have module a.py
> A = 100
> import b
> print "A printing"
> print "B is %s" % b.B
>
> and module b.py
> B = 2000
> import a
> print "B printing"
> print "A is %s" % a.A
>
> I thought that output would be:
> B printing
> A is 100
> A printing
> B is 2000
>
> Because import b would execute b.py, and in b.py line "import a" would be
> ignored, but my output is:
>
> >>> import a
>
> 100
> A printing
> B is 100
>
> ??
>
> :)
>
> --http://www.nacional.hr/articles/view/23894/23

a.py
=======
A = 100
import b
print "A printing"
print "B is %s" % b.B

b.py
=======
B = 2000
import a
print "B printing"
print "A is %s" % a.A

Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import a
B printing
A is 100
A printing
B is 2000
>>>

Looks okay to me.




More information about the Python-list mailing list