Hi, there.

I have two files:

a.py:

> # -*- coding: utf-8 -*-
> print('in a')
> import b
>
> print('var')
> VAR = 1
>
> def p():
>     print('{}, {}'.format(VAR, id(VAR)))
>
> if __name__ == '__main__':
>     VAR = -1
>     p()
>     b.p() # Where does this VAR come from?
>

b.py:

> # -*- coding: utf-8 -*-
> print('in b')
> import a
>
> def p():
>     a.p()
>

I don't understand why there're two different VARs, which is supposed to
the same.
Is it a bug?
If I move the 'main' block to another file, everything works well.

c.py:

> # coding=UTF-8
> import a
> import b
>
> if __name__ == '__main__':
>     a.VAR = -1
>     a.p()
>     b.p()
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to