initialization in python

koranthala at koranthala at
Thu Jan 1 13:44:33 CET 2009

How does an average product handle initialization in python?
I am facing lot of issues in handling initialization, especially if I
import specific variables, due to the variables not getting updated.

For example - taking a sqlalchemy based product:
Module database:
Session = None

def init(dbname):
   engine = create_engine('sqlite:///%s' %dbname)
   global Session
   Session = sessionmaker(bind=engine)

In entry module to the application (APPENTRY):
import A, B, C, D  <---- Please note, very important

Now in user module A:
from database import Session
print Session
--->This will print None, because at APPENTRY, during importing A
itself, Session is stored.
I have to call database.Session to get the values.

Why is the variable not getting updated? Can anyone help me out?

More information about the Python-list mailing list