singleton ... again
On Wednesday, February 12, 2014 11:57:02 PM UTC+2, Gregory Ewing wrote:
> 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
> other languages.
> _the_whatsit = None
> def get_whatsit():
> if _the_whatsit is None:
> _the_whatsit = Whatsit()
> return _the_whatsit
Gregory Ewing and Michael Torrie, yes you are both right, that is how things
are done in standard Python library. But i am not restricting myself to that.