开发者

is there a difference between class(): and class(object): in python 2.6-3.x?

Before py2.6 it's been answered here. Difference between class foo and class foo(object) in Python

But for python2.6+ and python3.x, is the first one wrong?

class Foo(): pass开发者_JAVA百科 vs class Foo(object): pass


For Python2.6+, before Python 3.0, the former creates an old-style class while the latter creates a new-style class. In Python 3.0, both create a new-style. The first isn't wrong, but for anything before 3.0 it has different semantics than the latter and is typically discouraged.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜