The Python standard library and PEP8

Aahz aahz at
Mon Apr 20 02:08:52 CEST 2009

[BTW, please make sure to retain attributions for quotes]

In article <mailman.4184.1240176321.11746.python-list at>,
Emmanuel Surleau  <emmanuel.surleau at> wrote:
>> What makes you think Python is "an OO language"? 
>Python is a dynamic object-oriented programming language that can be used 
>for many kinds of software development.
>First line on the Python official website. Was this a trick question?

Yes.  Although Python is frequently described as "object-oriented", that
fails to capture all that is Pythonic; Python is also procedurally
oriented and has a lot of functional capabilities.  Don't mistake a
one-line blurb for an accurate description.

>> What kind of OO
>> language allows you to do this:
>> def square(x):
>>     return x*x
>> for i in range(10):
>>     print square(x)
>Ruby, for instance.
>Allowing for procedural-style programming does not mean that a language 
>does not implement (even imperfectly) an OO paradigm.

"Allowing" is the wrong term here.  Python absolutely encourages a
straightforward procedural style when appropriate; unlike Java, there is
no attempt to force object orientation everywhere.  Appealing to Python's
"object-oriented" nature when arguing about design decisions and ignoring
the other programming styles it supports is an indicator that you don't
really know Python very well.

Also, my code sample was itself a trick question.  Python has *dynamic*
object orientation (just as the blurb says), and square() will work
on any object with a __mul__() method (through the ``*`` syntax), just as
len() works on any object with a __len__() method.  So my code
demonstrates the way Python's programming styles interleave with each
other (throw in a listcomp to complete the set).

Here's a quote for you:

"Programming language design is not a rational science. Most reasoning
about it is at best rationalization of gut feelings, and at worst plain
wrong."  --GvR, python-ideas, 2009-3-1
Aahz (aahz at           <*>

"If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur."  --Red Adair

More information about the Python-list mailing list