Encapsulation, inheritance and polymorphism

Chris Angelico rosuav at gmail.com
Wed Jul 18 17:04:50 CEST 2012


On Thu, Jul 19, 2012 at 12:40 AM, Lipska the Kat
<lipska at lipskathekat.com> wrote:
> Python looks like an interesting language and I will certainly spend time
> getting to know it but at the moment it seems to me that calling it an
> Object Oriented language is just plain misleading.

Python isn't object oriented in the way Java is ("EVERYTHING has to be
in a class! Look, it's all OO now!"). It simply says that, well,
what's the difference? That integer you're holding. That's an object.
Your function is an object. The module you're in, your "global scope",
is an object too, and can be passed around. Python doesn't care about
buzzwords, it cares about making code.

Of course, the simplicity of Python's object model has its costs too.
Every little integer has to be memory-managed and garbage-collected
(eg in CPython, they're all refcounted). That has a performance hit.
But not all that big a hit, and it is so handy when you want your
function to be able to accept, and distinguish between, different
types of object - you don't have to write one version that takes an
integer and a different one that takes a heap object.

ChrisA



More information about the Python-list mailing list