Costly object creation (was : Having Trouble with Scoping Rules)

Charles Krug cdkrug at
Tue Jan 31 08:15:42 EST 2006

On 2006-01-31, bruno at modulix <onurb at xiludom.gro> wrote:
> See other answers in this thread for how to solve the UnboundLocalError
> problem.
> Now about your *real* problem - which is nothing new -, you may want to
> read about some known solutions:

No, I'm already quite certain that this is a Singleton--pythonically a
module-level instance of Something--I'm not thinking of it as "lazy
instantiated" 'cuz it's initialized at startup, but I suppose it

I considered using a Borg for this, but discarded the idea as "too
complicated for my needs--this will be easier to implement . . . "

Which I suppose it would be if I knew how correctly to use the "global"

I don't need to restrict the actual class to One Instance so much as I'd
prefer that to be the default behavior.  I can't think of a reason why
I'd want to subclass this, so I can't say whether it makes sense to
Borg/Highlander/Singleton it or not.  For now, I'll Do The Simplest
Thing That Might Work and figure YAGNI (or IAGNI, I guess).

Thanks for the help.

More information about the Python-list mailing list