Re: a qustion about import that really confuses me

2011-11-22 Thread Dave Angel
On 11/22/2011 05:18 AM, David Lu wrote: 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?

a qustion about import that really confuses me

2011-11-22 Thread David Lu
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