This Python OOP explains to you the Python object-oriented programming clearly so that you can apply it to develop software more effectively.
By the end of this Python OOP module, you’ll have good knowledge of object-oriented principles. And you’ll know how to use Python syntax to create reliable and robust software applications.
What you’ll learn
- Create objects in Python by defining classes and methods.
- Extend classes using inheritance.
- Understand when to use object-oriented features, and more importantly when not to use them.
Who this tutorial is for
If you’re new to object-oriented programming, or if you have basic Python skills and wish to learn in-depth how and when to correctly apply OOP in Python, this is the tutorial for you.
Section 1. Classes and objects
- Classes and objects – learn how to define a class and create new objects from the class.
- __init__() method – show you how to define a constructor for a class by using the __init__() method.
- Class attributes – understand class attributes and more importantly when you should use class attributes.
- Private attributes – learn about private attributes and how to use them effectively.
- Static methods – explain to you static methods and shows you how to use them to group related functions in a class.
Section 2. Special methods
- __str__ method – show you how to use the __str__ dunder method to return the string representation of an object.
- __repr__ method – learn how to use the __repr__ method and the main difference between __str__ and __repr__ methods.
- __eq__ method – learn how to define the equality logic for comparing objects by values.
- __hash__ method – show you how to make a class hashable using the __has__ method.
- __bool__ method – guide you on how to determine whether a custom object is True or False using the __bool__ method.
- __del__ method – understand how the __del__ method works
Section 4. Advanced OOP
Section 5. Property
- Property– show you how to use the property class to create a proeprty.
- @property decorator – learn how to use the @property decorator to create a property.
- Read-only property – learn how to define read-only properties and use them for calcualted properties.
- Delete a property – guide you on how to delete a property from an object.