Hello

It's not clear to me what arguments are passed to the
__new__ method. Here is a piece of code:


class Premiere:

   def __new__(cls, price):
        return object.__new__(cls)

   def __init__(self, price):
           pass

p = Premiere(1000)

No errors, so it seems that 2 arguments are passed
to __new__, cls and price.


But if i do:


class Premiere:

   def __new__(cls, price):
       return object.__new__(cls, price)

   def __init__(self, price):
       pass

p = Premiere(1000)


it fails. It is strange because according to me it is equivalent to:


class Premiere:

   def __init__(self, price):
        pass

p = Premiere(1000)


which is OK.




--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to