Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the name of the region between parentheses after the class name in Python?

Tags:

python

For a function definition you'd speak of the "arguments" or "signature" of the function but is there a similar name for the list of parent classes and keyword arguments (since __init_subclass__) that can be used for classes? How could I refer to this when writing documentation?

# Parameters, arguments, function signature
#       v----------v
def func(arg1, arg2):
  pass

# Similarly, what's this called?
#        v-----------------------------v
class Cls(Parent, Mixin, mixin_arg=True):
  pass
like image 967
Robin De Schepper Avatar asked Sep 13 '20 11:09

Robin De Schepper


People also ask

What goes in the parentheses of a class in Python?

The parentheses in class definitions are for defining from which class you inherit. You don't write def in front of it, and when you inherit from 'object' which is the default you don't need the parentheses for the definition.

What does empty parentheses mean in Python?

Empty parentheses mean that the function you are calling takes no arguments or it has default arguments pre-defined. When a function is part of a class, we call it "method". Example: Python has a built-in class called str (string), to represent a sequence of characters.

What is a class in Python?

Python is an object oriented programming language. Almost everything in Python is an object, with its properties and methods. A Class is like an object constructor, or a "blueprint" for creating objects.

How do you call a function inside a class in Python?

To call a function within class with Python, we call the function with self before it. We call the distToPoint instance method within the Coordinates class by calling self. distToPoint . self is variable storing the current Coordinates class instance.


1 Answers

From my Python manual's specification for a class definition, perhaps we should call it the inheritance argument list:

enter image description here

like image 115
Booboo Avatar answered Sep 21 '22 11:09

Booboo