[Tutor] What is "pythonic"?

Eric L. Howard elh at outreachnetworks.com
Fri Oct 24 15:34:32 EDT 2003


At a certain time, now past [Oct.24.2003-12:14:05PM -0700], simple_stuff at hotmail.com spake thusly:
>    I've seen frequent reference on this list and in other Python
>    resources to the adjective 'pythonic'. For now I am translating
>    "pythonic" as "takes good advantage of the expressive qualities of the
>    Python language". However, as a newcomer to the language, I'm finding
>    this translation doesn't always allow me to understand the point that
>    is being made (especially when there is no attempt to elaborate beyond
>    a bland assertion that some code is or is not 'pythonic'). Can anyone
>    suggest some resources that have a number of code examples that
>    illustrate 'pythonic' vs. 'non-pythonic' style?

Python 2.2.3 (#1, Aug  1 2003, 12:54:19)
[GCC 3.2.3 20030422 (Gentoo Linux 1.4 3.2.3-r1, propolice)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>> 

       ~elh

-- 
Eric L. Howard           e l h @ o u t r e a c h n e t w o r k s . c o m
------------------------------------------------------------------------
www.OutreachNetworks.com                                    313.297.9900
------------------------------------------------------------------------
JabberID: elh at jabber.org                 Advocate of the Theocratic Rule



More information about the Tutor mailing list