DEV Community

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

Posted on • Edited on

M - Glossary (Python)

Buy Me a Coffee

method (meth)

  • is the function definded in a class.
  • There are 4 methods instance, class, static and bare method:
    • instance method (insmeth)

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

      • 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 (stameth)

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

      • 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)