0

I am confused on what the folowing means:

class class_name(object):

What does the class takes in between the parenthesis? is it inheritance?

kartikeykant18
  • 1,737
  • 6
  • 28
  • 42

4 Answers4

1

It's the superclass. There can be more than one, though getting that right and making it useful can be a bit tricky. There can also be none, but unless you're on Python 3, that's a bad idea.

user2357112
  • 260,549
  • 28
  • 431
  • 505
0

Basically it is inheritance. You might find this thread and some of the related links useful: Python class inherits object.

Community
  • 1
  • 1
Tim Wilder
  • 1,607
  • 1
  • 18
  • 26
0

Yes. It's inheritance. This is what it looks like:

class DerivedClass(BaseClass)

In your declaration, you're basically inheriting the object type. It's a built-in. However, in Python 3 you don't need to do this, as every class is implicitly a subclass of object.

By the way, more about this here.

aIKid
  • 26,968
  • 4
  • 39
  • 65
0
class class_name(object):

This is called inheritance
Python also supports multiple inheritance , that means you can inherit from multiple classes
for example:
class class_name(BaseClassName1,BaseClassName2,BaseClassName3):

Odai Al-Ghamdi
  • 302
  • 2
  • 12