modules share variables without class def

Ulrich Backes ulrich.backes at trw.com
Mon Nov 4 04:20:42 EST 2002


Hi there,

from several postings, i compiled the following scheme:

# test.py:
from func import testf
import globalvars
globalvars.port = 1
print testf() # -----> 1 OK!

# globalvars.py:
port = None
global port

# func.py:
import globalvars
def testf():
  return(globalvars.port)

That works. But if i try to use the blank variable name, it fails:

# test.py:
from func import testf
from globalvars import port
port = 1
print testf() # -----> None...

# globalvars.py:
port = None
global port

# func.py:
from globalvars import port
def testf():
  return(port)

Thanks for your advice,

Ulrich



More information about the Python-list mailing list