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.

cog wheels

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

instructor-led training course

Enjoying this page? We offer live Python training courses covering the content of this site.

See: Live Python courses overview

Upcoming online Courses

Enrol here

In this chapter

1. Object Oriented ProgrammingGeneral introduction in object-oriented Programming and the way it is used in Python
2. Class vs. Instance AttributesObject-oriented programming in Python: instance attributes vs. class attributesand their proper usage.
3. Properties vs. Getters and SettersObject oriented programming in Python: instance attributes vs. class attributesand their proper usage.
4. Creating Immutable Classes In PythonExplore Python's immutable classes for enhanced data integrity on your website. Learn the benefits of immutability with examples!
5. Dataclasses In PythonDive 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 ClassPython Class implementing a custom property class.
7. Magic MethodsPython Tutorial: Magic methods and operator overloading with examples. __call__ method to turn class instances into callables
8. Dynamic Data TransformationDiscover Dynamic Data Transformation in Python through an extensive course example featuring the Product class,
9. Introduction to DescriptorsIntroduction to descriptors. Defining descriptors, summarizing the protocol, and showing how descriptors are called.
10. InheritanceTutorial on Python: Inheritance
11. Multiple InheritanceObject-Oriented Programming in Python: Covering Multiple inheritance, the diamond problem, MRO and polymorphism in Python''
12. Multiple Inheritance: ExampleExtensive example of multiple inheritance in Python
13. Callable Instances of ClassesPython Tutorial: Callables in Python and class instances which can be used like functions. Introduction in the __call__ method
14. Slots: Avoiding Dynamically Created AttributesSlots in Python: A way to prevent the dynamical creation of attributes and to save memory space in certain cases
15. Polynomial ClassPython Class implementing polynomial functions.
16. Dynamically Creating Classes with typeRelationship 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 MetaclassesIncentive and motivation for learning and using metaclasses. Example classes,which could be designed by using metaclasses
18. MetaclassesTutorial on Metaclasses, theory, usage and example classes using metaclasses
19. Count Function calls with the help of a MetaclassUse Cases for Metaclasses: Counting Function Calls
20. The 'ABC' of Abstract Base ClassesAbstract Classes in Python using the abc module
21. OOP Purely FunctionalIntroduction in writing functions in OOP style, connection between functional programming and OOP