# Classes in Python
Last edited: 2023-11-11
Classes
in python are defined by the class keyword
for example.
class NewThing:
def __init__(self, variable):
self.variable = variable
When using classes you use the self keyword
to refer back to the object. Therefore a class method
requires to have the first argument as self.
Special functions
# __call__
When a class has this property it makes it callable. For example:
class SayMyName:
def __call__(self):
print("Alex Wendland")
>>> say_it = SayMyName()
>>> say_it()
Alex Wendland