Imports in python are static, any solution?

Luis Alberto Zarrabeitia Gomez kyrie at uh.cu
Mon Apr 13 12:10:45 EDT 2009


Quoting Ravi <ra.ravi.rav at gmail.com>:

> 
> This is problematic. Well I want i to change with foo.fi() .

You can't. i and foo.i are _different_ variables that just happen to share the
same value initially. What you are observing is no different than

i = 10
j = i
i = 99

print i  # prints 99
print j  # print 10

May I ask, why is it problematic? You should be avoiding the use of global
variables anyway.

-- 
Luis Zarrabeitia
Facultad de Matemática y Computación, UH
http://profesores.matcom.uh.cu/~kyrie

-- 
Participe en Universidad 2010, del 8 al 12 de febrero de 2010
La Habana, Cuba 
http://www.universidad2010.cu




More information about the Python-list mailing list