How to have application-wide global objects

Sanjay skpatel20 at hotmail.com
Thu Jul 13 11:59:32 EDT 2006


Hi Bruno,

Thanks a lot for the reply. In order to post here, I wrote a very
simple program now, and it seems working! I can diagnose the original
problem now. There might be some other problem.

Pardon me if I am too novice but I could not make out the meaning of
this phrase from your reply:

"(at the module's to level)"

Thanks
Sanjay
------------------------------------------------------------------
Bruno Desthuilliers wrote:
> Sanjay wrote:
> > Probably a newcomer question, but I could not find a solution.
> >
> > I am trying to have some singleton global objects like "database
> > connection" or "session" shared application wide.
>
> Whenever possible, dont. If you really have no other way out, create the
> 'singleton' in it's module (at the module's to level), then import the
> module.
>
> > Trying hard, I am not even being able to figure out how to create an
> > object in one module and refer the same in another one. "import"
> > created a new object, as I tried.
>
> I'd like to know what you actually tried.
>
>
> --
> bruno desthuilliers
> python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
> p in 'onurb at xiludom.gro'.split('@')])"




More information about the Python-list mailing list