DEV Community

Super Kai (Kazuya Ito)
Super Kai (Kazuya Ito)

Posted on • Edited on

M - Glossary (Python)

Buy Me a Coffee

method

  • is a function definded in a class.
    • instance method

      • is to use instance variables, and instance, class, static and bare methods.
      • must have the 1st parameter self:
        • By convention, self is used instead of other names.
    • class method

      • is to use class variables, and class, static and bare methods.
      • is to be used by instance methods.
      • must have the 1st parameter cls:
        • By convention, cls is used instead of other names.
    • static method

      • is to be used by instance and class methods.
      • is more powerful than a bare method so use it.
    • bare method

      • is to be used by instance and class methods.
      • is less powerful than a static method so don't use it.
    • 4 methods can be called by an instance and class object.

Top comments (0)