[Tutor] newbie Python Modules

Guess?!? wtfwhoami at gmail.com
Mon Jun 16 22:38:21 CEST 2008


*Module Name eli.py*

x = 0

y = [1, 2]

print 'Running module "eli"'

def whitney():

print 'whitney'

def printValues():
print x , y

*When I imported the Module*

from eli import x, y, printValues

printValues()

y[0] = 'cat'

x = 'dog'

printValues()

Output

Running module "eli"

0 [1, 2]

0 ['cat', 2]
Can Someone explain this to me? Why x remains 0 ....Is it because x = 'dog'
is local variable and y being a list is a mutable object that is changed
easily.
Also once we reload the module .... every value reverts to its original
value .. Am I Right?

Thanks,
G
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080616/b1d76e7d/attachment-0001.htm>


More information about the Tutor mailing list