0

If I write this, the new method will not be called

class MyClass:
    @classmethod
    def __new__(cls, *args, **kwargs):
        print "here"

if __name__ == "__main__":
    c = MyClass()

but when i write like this, the new method will be called when calling MyClass what's the mainly difference when a class sub child object or not?

class MyClass(object):
    @classmethod
    def __new__(cls, *args, **kwargs):
        print "here"

if __name__ == "__main__":
    c = MyClass()
python
  • 1,870
  • 4
  • 24
  • 35

0 Answers0