Why do directly imported variables behave differently than those attached to imported module?
Dun Peal
dunpealer at gmail.com
Tue May 3 12:31:06 EDT 2011
Hi!
Here's the demonstrating code:
# module foo.py
var = 0
def set():
global var
var = 1
Script using this module:
import foo
from foo import *
print var, foo.var
set()
print var, foo.var
Script output:
0 0
0 1
Apparently, the `var` we imported from `foo` never got set, but
`foo.var` on the imported `foo` - did. Why?
Thanks, D.
More information about the Python-list
mailing list