Newbie namespace question

Nick Coghlan ncoghlan at
Thu Dec 23 08:39:59 CET 2004

Brandon wrote:
> Peter,
> You're correct about the bug.  I did need a 'self' parm...  I was just
> winging the example because the actual code is pretty large.  I'm using
> google groups for my posting and it didn't carry spaces through (I did
> use spaces and not tabs).
> The "fix" or workaround was to import __builtin__ and add the
> AdminConfig reference there in as follows:
> import __builtin__
> __builtin__.AdminConfig = AdminConfig
> As for the indentations, substitute ~ with a space.
> Hopefully, a bug free and "indented" version.  :)
> class DataSource:
> ~~~def __init__(self, servername):
> ~~~~~~self.servername = servername
> ~~~def create(self, name, connectionInfo, etc):
> ~~~~~~#Call the IBM supplied WebSphere config object
> ~~~~~~AdminConfig.create('DataSource')

Is there any particular reason DataSource can't be modified to accept a 
reference to the AdminConfig as a constructor argument? Or as a class attribute?

Alternatively, here's another trick to 'nicely' set a module global from outside 
a module:
def setAdminConfig(adm_cfg):
   global AdminConfig
   AdminConfig = adm_cfg

However, if you would prefer not to alter, consider trying:

import jdbc
jdbc.AdminConfig = AdminConfig

Global variables are bad karma to start with, and monkeying with __builtin__ is 
even worse :)


Nick Coghlan   |   ncoghlan at   |   Brisbane, Australia

More information about the Python-list mailing list