singleton ... again
greg.ewing at canterbury.ac.nz
Wed Feb 12 22:57:02 CET 2014
Asaf Las wrote:
> There is another one.
> Once object passes through singletonizator
> there wont be any other object than first one.
> Then object constructor can freely be used in every place
> of code.
You're still making things far more complicated
than they need to be.
*Why* do you want to be able to use the object
constructor, instead of just using the prebuilt
If you want to hide the distinction between using
call syntax and just accessing a global, then
export a function that returns the global instance.
That function can even lazily create the instance
the first time it's called. That's a pattern that
*is* useful, and I've often used in Python and
_the_whatsit = None
if _the_whatsit is None:
_the_whatsit = Whatsit()
More information about the Python-list