What is the exact difference among these three and when do we use what?
class A:
pass
class A(object):
pass
or
class A():
pass
What is the exact difference among these three and when do we use what?
class A:
pass
class A(object):
pass
or
class A():
pass
class A:
pass
It is implicitly subclass of object
(as in other cases). I think it's most prefereable in case you don't inherit from anything (but it can depend on coding standards).
2)
class A(object):
pass
It is most explicit version.
3)
class A():
pass
In this case, as no class passed as parent class, by default it inherits from object.
So from functionality point of view, there is no difference. In Python3, all clasess inherit from object
(even if it's not explixitly declared).
However, if you are using Python2, you need to pass superclass explicitly in every case.