DEV Community

Cover image for Is Python Object-Oriented or Procedural Language
TechCluesBlog
TechCluesBlog

Posted on • Originally published at techcluesblog.com

Is Python Object-Oriented or Procedural Language

Python is widely used in the programming language of today. It has gained great success in the field of scripting, data analytics, machine learning and much more.

But, as a programmer and developer, it becomes mandatory to verify if Python supports the concepts of Object-Oriented Programming Language (OOPS)

Read a detailed tutorial at Is Python Object Oriented

Top comments (1)

Collapse
 
codemouse92 profile image
Jason C. McDonald

Python is officially multi-paradigmatic. It fully supports all the design patterns and principles of Object-Oriented Programming Functional Programming, and Procedural Programming. You can write purely in any one of the paradigms, albeit with some discretion if you're targeting Functional, or you can combine them.

In terms of Object-Oriented Programming, SOLID is entirely supported. Inheritance and abstract classes work as they should. Any and all of the OOP design patterns can be implemented in Python, although none are strictly required.

Perhaps the only OOP oddity about the language is the lack of data hiding. However, this is only an artificial issue: Python uses the social convention of preceding "non-public" attributes with _ to indicate they aren't supposed to be modified. Name mangling can also be invoked by preceding a name with __, although this is intended to prevent name collisions in inheritance, not to actually hide data.

Additionally, support for any built-in function or language feature can be added to any class just by implementing the necessary special (or "dunder") methods. For example, implementing the __next__() method makes that class an iterable.

So, yes, Python is fully Object-Oriented, but OOP is not mandatory when using the language.