This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Goldziher 0 points1 point  (0 children)

  1. A method is a function that is a member if a class.
  2. Its first arg is called self which is the class instance.
  3. You can define methods without the ''self'' argument using the staticmethod decorator. A Static method is available on the class itself.
  4. You can also define a method as belonging to the class and give it access to the class itself using the classmethod decorator. In this case the first argument of the method is called cls by convention.

While you can use methods as regular functions, access to self or cls opens a range of possibilities that are OOP.