< BACKMake Note | BookmarkCONTINUE >
152015024128143245168232148039199167010047123209178152124239215162147039203228125244193003

Object-Oriented Programming

Python uses the traditional class architecture for object-oriented programming (OOP).

The object-oriented model adopted by Python

  • Promotes modular design

  • Promotes and facilitates Python software reusability

  • Uses notions of real-world objects to develop programs

  • Results in better quality software (but, of course, you can write bad code with any paradigm)

Object-oriented programming promotes data abstraction, information hiding, encapsulation, and modular programming.

Saying that OOP promotes data abstraction means that we define the functions that operate on the data. The ideal scenario provides encapsulated data that can be accessible only through the class methods. However, in Python, we cannot totally block the programmer from accessing the information that is stored inside a class.

Encapsulation, Inheritance, and Polymorphism are the most important thoughts provided by OOP. Python doesn't strictly follow the standard concepts, but you will see how far it goes.

Encapsulation—  Data can only be accessed or manipulated by means of a set of interface functions. Encapsulation of data enables information hiding. Python provides encapsulation through conventions rather than strictly enforcing it, which can be preferable.

Inheritance—  With inheritance, the derived class (also known as subclass, descendant, or child class) inherits the data members and class methods of its base (parent) class.

Polymorphism—  It enables a function to have several different kinds of interfaces. Depending on the parameters used by the caller, the class knows which interface should be used. Python achieves this through its dynamic typing and late binding.


Last updated on 1/30/2002
Python Developer's Handbook, © 2002 Sams Publishing

< BACKMake Note | BookmarkCONTINUE >

Index terms contained in this section

object-oriented programming (OOP)
programming
      object-oriented (OOP)

© 2002, O'Reilly & Associates, Inc.