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 vs class Foo(object): pass
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.