Python FAQ: Python classes

how do I post a python FAQ? I can’t find it in the categories.

also: why do methods in classes always have to have a parameter self

self is the current instance of the class, which we can show with the following example:

class MyClass():
    def hello_world(self):
        print('hello world')

instance = MyClass()

when calling a method on class, python will handle the self parameter

this line:


you can see instance being passed to the self parameter (because the method is called on class, not on instance)

1 Like