Newbie namespace question

Nick Coghlan ncoghlan at
Thu Dec 23 13:59:04 CET 2004

Brandon wrote:
> I did the constructor thing and just didn't like it, it didn't feel
> clean (I know, I know and monkeying with __builtin__ is?)
> As for global, that will just make it modlue-level global (I think?)
> and I have this reference in multiple modules.  I think I tried it
> already, but I can't remember for sure...  Anyway, all of this got me
> brainstorming and I think I've got a solution that I think is clean and
> will be effective, I'll bust it out and post it here for comments.
> Thanks for your input!
Another option for you to consider:

#__main__ ( I forget the script's name)
import app_config

from jdbc import DataStore
  . . .etc
from app_config import AdminConfig
. . .etc
def setConfiguration(adm_cfg):
   global AdminConfig
   AdminConfig = adm_cfg

The reason the import solution was breaking for you earlier was that you were 
setting up circular imports by using your main script as the holder for the 
global configuration.

By creating a special 'configuration data' module, you can use that to store the 
data, and every module that needs it can import it without worrying about 
circular imports.

Any extra global configuration properties can be added by updating the 
'setConfiguration' function.


Nick Coghlan   |   ncoghlan at   |   Brisbane, Australia

More information about the Python-list mailing list