Feb-11-2018, 06:45 PM
(This post was last modified: Feb-11-2018, 06:46 PM by Gribouillis.)
(Feb-11-2018, 06:34 PM)bb8 Wrote: wouldn't __new__() get called every time a class a tried to be instantiated?No,
__new__
is called every time an instance of the metaclass _Singleton
is created. It means that it will be called every time a subclass of Singleton
is defined, but not when such classes try to be instantiated. You can check this easily by adding a print statement in __new__()