Class definition parameter vs. Normal class definition
This question already has an answer here:
In Python 2, the former is a "new-style class" and the latter is an "old-style class" that only exists for backwards compatibility. You should never use the latter for anything new.
In Python 3, I believe there is no difference at all. You can even leave out the parentheses entirely.
In two words:
# new style
class Car(object):
pass
A "New Class" is the recommended way to create a class in modern Python.
# classic style
class Car():
pass
A "Classic Class" or "old-style class" is a class as it existed in Python 2.1 and before. They have been retained for backwards compatibility. This page attempts to list the differences.
Please look at:
上一篇: Python类定义(对象)
下一篇: 类定义参数与普通类定义