Intro to Object Oriented Programming
By Bernd Klein. Last modified: 01 Feb 2022.
This section of our Python tutorial deals with object-oriented programming, usually abbreviated as OOP. It is difficult to summarize the essence of object orientation in a few sentences:
Object Oriented Programming (OOP) is a programming paradigm based on the concept of "objects" that can contain data and code. The data is often implemented as attributes. Functions implement the associated code for the data and are usually referred to in object oriented jargon as methods. In OOP, computer programs are designed by being made up of objects that interact with each other via the methods.
It was difficult for us to decide whether to add object-oriented programming to the beginner or the advanced level sections of our Python tutorial.
There are some who think it's best to combine learning Python with OOP from the start. This is vital in programming languages like Java. Python can be used without programming in an OOP style. Many beginners to Python prefer this, and if they only want to write small to medium-sized applications, this is good enough. However, for larger applications and projects, it is recommended to look into OOP. The following chapters describe almost all aspects of Python OOP.
We decided to introduce the basics of Python without going directly into object-oriented programming. Therefore, these chapters assume that you are familiar with the basics of Python.
Live Python training
Enjoying this page? We offer live Python training courses covering the content of this site.
Upcoming online Courses
In this chapter
Page | Description |
---|---|
1. Object Oriented Programming | General introduction in object-oriented Programming and the way it is used in Python |
2. Class vs. Instance Attributes | Object-oriented programming in Python: instance attributes vs. class attributesand their proper usage. |
3. Properties vs. Getters and Setters | Object oriented programming in Python: instance attributes vs. class attributesand their proper usage. |
4. Creating Immutable Classes In Python | Explore Python's immutable classes for enhanced data integrity on your website. Learn the benefits of immutability with examples! |
5. Dataclasses In Python | Dive into the power of Python's dataclasses on this page. Simplify class creation, enhance readability, and embrace efficient data management |
6. Implementing a Custom Property Class | Python Class implementing a custom property class. |
7. Magic Methods | Python Tutorial: Magic methods and operator overloading with examples. __call__ method to turn class instances into callables |
8. Dynamic Data Transformation | Discover Dynamic Data Transformation in Python through an extensive course example featuring the Product class, |
9. Introduction to Descriptors | Introduction to descriptors. Defining descriptors, summarizing the protocol, and showing how descriptors are called. |
10. Inheritance | Tutorial on Python: Inheritance |
11. Multiple Inheritance | Object-Oriented Programming in Python: Covering Multiple inheritance, the diamond problem, MRO and polymorphism in Python'' |
12. Multiple Inheritance: Example | Extensive example of multiple inheritance in Python |
13. Callable Instances of Classes | Python Tutorial: Callables in Python and class instances which can be used like functions. Introduction in the __call__ method |
14. Slots: Avoiding Dynamically Created Attributes | Slots in Python: A way to prevent the dynamical creation of attributes and to save memory space in certain cases |
15. Polynomial Class | Python Class implementing polynomial functions. |
16. Dynamically Creating Classes with type | Relationship between classes and type for advanced programmers: deeper insight into what happens when we define a class or create an instance of a class. |
17. Road to Metaclasses | Incentive and motivation for learning and using metaclasses. Example classes,which could be designed by using metaclasses |
18. Metaclasses | Tutorial on Metaclasses, theory, usage and example classes using metaclasses |
19. Count Function calls with the help of a Metaclass | Use Cases for Metaclasses: Counting Function Calls |
20. The 'ABC' of Abstract Base Classes | Abstract Classes in Python using the abc module |
21. OOP Purely Functional | Introduction in writing functions in OOP style, connection between functional programming and OOP |