On Thu, Jan 23, 2014 at 3:07 AM, Asaf Las <roeg...@gmail.com> wrote: > is it possible to create singleton using construct below : > > def singleton_provider(x = [None]): > if singleton_provider.__defaults__[0][0] == None: > singleton_provider.__defaults__[0][0] = SomeClass() > return singleton_provider.__defaults__[0][0] >
Why not simply: def get_singleton(x = SomeClass()): return x Or even: singleton = SomeClass() ? Neither of the above provides anything above the last one, except for late creation. ChrisA -- https://mail.python.org/mailman/listinfo/python-list