[Tutor] __init__ for class instantiation?

Zak Arntson zak@harlekin-maus.com
Mon Apr 28 13:27:01 2003


> Hello Zak,
>
> Friday, April 25, 2003, 9:00:54 PM, you wrote:
>
> ZA> The problem here (as with __new__) is that __init__ will be called
> with ZA> every creation of a Player instance.
>
> It seems that you are wrong here---__new__ is called only once after
> class is defined.
>
> --
> Best regards,
>  anton                            mailto:antonmuhin@rambler.ru

I created a new class, and defined __new__, but it doesn't get called from
Python, as far as I can tell. Here's my code:

class C:
     def __new__ (cls):
          print (cls)

Even when I create the first instance (d = C()), I don't get any output.