0

What is difference between these two type of class declarations?

class ClassName():

class ClassName(object):

What does this object parameter does?

2
  • 4
    In Python 3, there is no difference, since all classes implicitly inherit from object Commented Sep 18, 2018 at 6:01
  • In Python 3 you don't even need the brackets, just use class Foo:. Commented Sep 18, 2018 at 6:05

1 Answer 1

1

In Python 2 from 2.1, there are two kinds of classes, new-style and classic. Deriving from object in Python 2, from 2.1 on, will create a new-style class. In Python 3, there's only one kind, and so both forms are the same.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.