This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author crayor
Recipients crayor
Date 2008-05-20.15:16:33
SpamBayes Score 0.0007529448
Marked as misclassified No
Message-id <1211296598.61.0.428174810235.issue2930@psf.upfronthosting.co.za>
In-reply-to
Content
How can I change a variable that I defined in "__init__.py" of a 
package called "common" from inside the .py file that imported the 
package? I think there is no way to do this, in contrast to when the 
variable is defined any other module of the same package but not in the 
specific "__init__.py" module.

Example:
If there is a variable named let's say "fileList" in the 
module "var.py" of the package "common" then I could modify the 
variable "fileList" from within the importing file like this:

from common.var import *
var.fileList = [ "bla", "blub" ]

So that the change of the value of "fileList" is seen when reading it 
inside a function of "var.py" after this modification.

But when the variable is defined inside "__init_.py" then the importing 
script cannot access it by writing:

from common import *
fileList = [ "bla", "blub" ]

And it cannot access it by writing:

from common import *
common.fileList = [ "bla", "blub" ]

Why are variables of "__init__.py" module non-modifyable this way and 
all others of submodules of the same package are modifyable? Maybe 
there is this conceptional problem of the python language here or did I 
miss something?
History
Date User Action Args
2008-05-20 15:16:39crayorsetspambayes_score: 0.000752945 -> 0.0007529448
recipients: + crayor
2008-05-20 15:16:38crayorsetspambayes_score: 0.000752945 -> 0.000752945
messageid: <1211296598.61.0.428174810235.issue2930@psf.upfronthosting.co.za>
2008-05-20 15:16:37crayorlinkissue2930 messages
2008-05-20 15:16:35crayorcreate