🐍 Python Beginner

What is object-oriented programming in Python?

Answer

Python supports full OOP through classes. Define a class: class Animal: def __init__(self, name): self.name = name; def speak(self): raise NotImplementedError. Instantiate: dog = Animal("Rex"). Inheritance: class Dog(Animal): def speak(self): return "Woof!". Call parent: super().__init__(name). Access modifiers: Python uses naming conventions — public (regular), _protected (single underscore, convention only), __private (double underscore, name mangling to _ClassName__attr). Class methods: @classmethod def create(cls, name): return cls(name). Static methods: @staticmethod def validate(name): return bool(name). Python supports multiple inheritance: class C(A, B) with MRO (Method Resolution Order) using C3 linearization.