oops concepts in python with example. Object oriened programming in Python.

Python is a multi-paradigm programming language. It means that Python accommodate separate programming approaches. One approach which already existed since Python was created is object oriented programming (OOP). OOP is a programming paradigm which equips a technique of organizing programs so that property and behavior are combined and wrap it inside an object.

The main concept behind OOP is classes and objects. We can see a class as a 'blueprint'  for objects which can have their own attributes (properties) and methods (behaviors). OOP is commonly used to write a large program or solving a problem that is better suited to this method.

The OOPs concepts are relatively more complex than other programming paradigms. It require steeper learning curve for beginners. Moreover, it requires more memory and OOP software is slower. Nevertheless, the development is faster and cheaper and the software is easier to maintain. As a result, the software has higher quality and extensible with new attributes and methods.

The focus of OOP in Python is on creating reusable code, or well-known as don't repeat yourself (DRY) concept.

Enroll Nanodegree in Programming with Python Now!

 If you still confuse or even do not understand anything I mentioned on earlier paragraphs, don't be intimidated. I have experienced the same situation, despite I have learned several Python OOP tutorials. We will encounter more terminologies in OOP such as class variable, instance variable, inheritance, instance, instantiation and other. All you have to do is consistently learning from high quality resources, just like what I have shared in previous post.

Below are three YouTube channels with the best object oriented programming Python tutorials. It is better to follow more than one channel. It's not only important to gain different insights but also repeating common concept and make you understand deeper.

1. Corey Schafer




Corey Schafer is definitely one of the best Python YouTuber. I put him in my first list of Python basic tutorials, and now he is also in my number one list for Python OOP. And the reasons are essentially similar. He prepared the materials really well and deliver it in a clear and concise presentation.

He created six videos dedicated to explore Python OOP thoroughly. I love his real live example he used in this tutorial, it's about employee data. The topics he covered include:
  • How to create a class and instantiate objects
  • What is a class variable and how to use it
  • Difference between classmethods and staticmethods
  • Concept of class inheritance
  • Special methods (magic/dunder methods)
  • Property decorator

2. Richard White





Richard White has only two videos covering OOP in Python, but both are more than 30 minutes long. He explained this topic bit by bit and allow us to digest this subject comfortably. In addition, He gave a good example of putting comments and docstrings to each parts of the program. In the first video, he gave an example of building a contact list of our friends. On the other hand, he gave an example about wardrobe and clothing he wears. Really simple examples but make us understand this complex concept easier.

Moreover, Richard made some notes on a piece of paper before starting to code. I found that this extra explanation is so helpful to grasp the bigger picture before going into detail of Python OOP scripts. Another concept that he described clearly is getter and setter methods.

3. Ashwin Pajankar





This is the Python OOP tutorial from A to Z. Ashwin didn't only created 30 videos but he also provided an e-book of Python OOP and its free. He explained every aspects of Python OOP in great detail. There are so many Python OOP features he covered that can't be found in any other YouTube tutorials.

The init method, which commonly in the first or second video of a Python OOP tutorial, was presented in the fifth video of his tutorial. This means that he explained various aspects of class, object, attribute and method in his four earlier videos. He even had two videos which covered docstrings and multi-line docstrings respectively. Other specific subject that can't be found on any other YouTube tutorials include:
  • Polymorphism and overriding
  • Hierarchical inheritance
  • Multilevel inheritance
  • Hybrid inheritance
  • Abstract class
If you need more in depth exploration of OOPs in Python, you can learn from Mastering Object-oriented Python book. This book provides a clear and coherent learning journey and designed to make this sophisticated approach to programming easier to learn quickly.


2 Comments

  1. Thank you for showing the best Python OOP tutorials.

    ReplyDelete
    Replies
    1. You are welcome. Hope you can learn fast from them.

      Delete