Message67128
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? |
|
Date |
User |
Action |
Args |
2008-05-20 15:16:39 | crayor | set | spambayes_score: 0.000752945 -> 0.0007529448 recipients:
+ crayor |
2008-05-20 15:16:38 | crayor | set | spambayes_score: 0.000752945 -> 0.000752945 messageid: <1211296598.61.0.428174810235.issue2930@psf.upfronthosting.co.za> |
2008-05-20 15:16:37 | crayor | link | issue2930 messages |
2008-05-20 15:16:35 | crayor | create | |
|