[Python-Dev] PEP 318 - posting draft
Phillip J. Eby
pje at telecommunity.com
Wed Mar 24 16:09:45 EST 2004
At 09:41 PM 3/24/04 +0100, Alex Martelli wrote:
>Perhaps something like...:
>
>class metaSingleton(type):
> def __new__(cls, classname, classbases, classdict):
> result = type.__new__(cls, classname, classbases, classdict)
> if classbases:
> return result()
> else:
> return result
By the way, there's a bug in the above implementation: it can't be safely
mixed with other metaclasses, because it calls 'type' directly instead of
using 'super()'.
More information about the Python-Dev
mailing list