new style classes, __new__, __init__

Christian Heimes lists at cheimes.de
Tue Sep 16 15:40:41 EDT 2008


Torsten Mohr wrote:
> I just found an article that describes it better, this example works:
> 
> class C2(object):
>     def __new__(cls, a):
>         obj = object.__new__(cls)
>         print "new called"
>         obj.a = 8
> 
>         return obj
> 
>     __new__ = staticmethod(__new__)

Staticmethod isnt' required here.


Christian




More information about the Python-list mailing list