how can I modify an imported variable ?

2006-12-27 Thread yomgui
I've tried this: import MyPackage if MyPackage.aVariable is None: MyPackage.aVariable = True but when I tried to access MyPackage.aVariable from another file (ie through an other import) the value is still None. how can I do this thanks yomgui --

Re: how can I modify an imported variable ?

2006-12-27 Thread Jean-Paul Calderone
On Wed, 27 Dec 2006 14:50:18 GMT, yomgui [EMAIL PROTECTED] wrote: I've tried this: import MyPackage if MyPackage.aVariable is None: MyPackage.aVariable = True but when I tried to access MyPackage.aVariable from another file (ie through an other import) the value is still None. how can I

Re: how can I modify an imported variable ?

2006-12-27 Thread yomgui
hi, your sample code works, but mine doesn't. it must be a multi-thread issue. I am certain that I am modifying MyPackage.aVariable before using it. Both threads are importing MyPackage, but the modification of MyPackage.aVariable is not seen by the other thread. is this possible ? is there a

Re: how can I modify an imported variable ?

2006-12-27 Thread yomgui
actually, it is not linked to threading but to the scope. the second attempt to access MyPackage.aVariable is inside the __init__ of a class and this seems to be the problem. I believe it is a genuine python bug. yomgui -- http://mail.python.org/mailman/listinfo/python-list

Re: how can I modify an imported variable ?

2006-12-27 Thread Carsten Haese
On Wed, 2006-12-27 at 18:10 +, yomgui wrote: actually, it is not linked to threading but to the scope. the second attempt to access MyPackage.aVariable is inside the __init__ of a class and this seems to be the problem. I believe it is a genuine python bug. Please post a minimal but

Re: how can I modify an imported variable ?

2006-12-27 Thread Gabriel Genellina
At Wednesday 27/12/2006 13:45, yomgui wrote: your sample code works, but mine doesn't. it must be a multi-thread issue. I am certain that I am modifying MyPackage.aVariable before using it. Both threads are importing MyPackage, but the modification of MyPackage.aVariable is not seen by the