Object Oriented Programming in Python

Python is a multi-paradigm programming language; meaning object-oriented, structured, functional and even aspect-oriented programming are supported. You can explore these programming styles further here.

Python’s object-oriented features use inheritance for code reuse and extensibility in the form of classes.  You don’t have to use classes in your Python projects, however once you understand how powerful they are chances are you’ll find places where they are appropriate.

Python has been object-oriented since it was created, however it wasn’t until Python 2.2 that, in Guido’s own words, it was done right. “This change was, by far, the most ambitious rewrite of a major Python subsystem to date” he wrote in The History of Python

Python OOP Resources

Real Python has a great overview of OOP in Python.  They discuss not just what classes are but why you might want to use them. This is a good place to start if OOP is new to you.

Anna-Lena Popkes created an interesting series of blog posts where she created a “little Magical Universe with classes and methods related to the Tales of Castle Kilmere”. I found this a very creative way of explaining OOP in Python. She was also a guest on Talk Python to Me where she discussed the her magical kingdom and object-oriented Python.

There is a great interactive course at DataCamp that introduces the internals of classes and the utilization of objects, as well as important object-oriented programming fundamentals such as inheritance, polymorphism, and composition.

DataCamp also has a very good tutorial about OOP in Python.

If you are interested in getting some practice with classes and objects in Python you could check out the Object-oriented programming tasks on CheckIO.

There is an OOP section over at Python School suitable for beginners.

This is a short, but thorough video tutorial on the Python’s built-in toolset for creating classes. Raymond Hettinger looks at commonly encountered OOP challenges and how to solve them using Python.

And finally, not to sound like a broken record, but Corey Schafer has some great OOP Python videos:

1 comment

  1. Like!! I write Python for my job. I only dislike this writing of this this.this, this.that, etc. with Python objects…

Leave a comment

Your email address will not be published. Required fields are marked *