Python
Tooling
Syntax
Different types of methods
class Example:
def __init__(self, value):
self.value = value
def instance_method(self):
print(f"Instance method, self.value = {self.value}")
@classmethod
def class_method(cls):
print(f"Class method, cls = {cls.__name__}")
@staticmethod
def static_method():
print("Static method (no self or cls)")
e = Example(42)
e.instance_method() # Bound to instance
Example.class_method() # Bound to class
Example.static_method() # No binding
Type
Decorator
First Parameter
Used For
Import
__name__
πΉ person.py
person.pyπΉ main.py
main.py__init.py__
Last updated