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,
selfis used instead of other names.
- By convention,
-
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,
clsis used instead of other names.
- By convention,
-
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)