New submission from Jörg Rebenstorf <[EMAIL PROTECTED]>:

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?

----------
components: Interpreter Core
messages: 67128
nosy: crayor
severity: normal
status: open
title: Cannot change variable definied in __init_.py after importing
type: behavior
versions: Python 2.3

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2930>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to