Jan-11-2018, 06:59 PM
(Jan-11-2018, 05:45 PM)fig0 Wrote: Can't I simple use the class __new__ magic method instead of creating a metaclass?I don't think so. There is nothing magic in the
__new__()
method. Its role is to create a raw object prior to intialization. I wouldn't try to use __new__()
to avoid calling the ancestor classes' constructor. It is not good design, and it will be difficult to handle several levels of inheritance.Python provides metaclasses as the normal way to handle such specific type requests. What do you think is wrong with using a metaclass?