[Tutor] __new__ and __init__
eryksun
eryksun at gmail.com
Wed Aug 1 18:00:21 CEST 2012
On Wed, Aug 1, 2012 at 11:10 AM, Hugo Arts <hugo.yoshi at gmail.com> wrote:
> On Wed, Aug 1, 2012 at 4:28 PM, rail shafigulin <rail.shafigulin at gmail.com>
>
> * small caveat: I'm entirely unsure of this, but I *think* if you create
> CarModel with a metaclass that overrides __call__ you can change the way
> __new__ and __init__ work? If anyone can confirm this, be my guest.
>
That works, but if you're going to use a metaclass (i.e. a type
subclass of which the CarModel class is an instance), you may as well
skip overriding __new__. You don't want to mess around with
metaclasses, however, unless absolutely necessary. Don't needlessly
complicate your code to make it harder to understand and maintain.
More information about the Tutor
mailing list