0

In python the new style of class declaration is this:

class A(object):
    pass

what I don't understand is what is wrong with the old declaration,

class A:
    pass

more specifically, why they needed to add the base object class.Also,I want to know a little bit more about the object class in python,couldn't find any resource available on object class.

However, What is the difference between old style and new style classes in Python? There's some answer over here,which talks about the rules but my specific question is what is the advantage of this declaration with object(Base class) on the declaration without the object.

Community
  • 1
  • 1
user3680660
  • 325
  • 1
  • 3
  • 6
  • 1
    New style classes can do more things; they support metaclasses, properties, class and static methods, etc. Subclasses of built-in types are new-style classes. – Martijn Pieters Jun 22 '14 at 18:39
  • One of the answers there *tells you all this*: [Old style and new style classes in Python](http://stackoverflow.com/a/19950198) – Martijn Pieters Jun 22 '14 at 18:41
  • 1
    Thanks @MartijnPieters, I would like to know more about object class,in java,The Object class has some methods which are useful,but a google search on object class in python does not seem to have any documentation on that.Don't they have any documentation on the object class? – user3680660 Jun 24 '14 at 15:11
  • The [datamodel](https://docs.python.org/2/reference/datamodel.html) tells you more than you want to know about what attributes and methods you can find on Python objects and custom classes. – Martijn Pieters Jun 24 '14 at 15:50

0 Answers0