Skip to content.

plope

Personal tools
You are here: Home » Members » chrism's Home » Unpythonic == Obscene
 
 

Unpythonic == Obscene

The notion of "Unpythonic" is a little pretentious.

Many references around the web refer to something as "unpythonic". Sometimes the thing that's referred to as unpythonic is a framework written in Python like Zope. Sometimes it's a configuration pattern (most recently the use of "configure; make; make install" vs. "python setup.py install" on the zope-dev list). Sometimes it's a small bit of code written in Python (e.g. things that overuse Python's functional keywords like "map", "filter", "reduce", "lambda" etc). Sometimes it's an API (e.g. the XML DOM).

The concept of "Pythonic" itself is meaningless. Even Guido can't define it :

 Guido van Rossum: That's a really tough question. One example of an API design I found unsatisfactory is the  
 DOM API for dealing with XML. That originally started in the Java world. I'm not sure if the problems with it  
 are the same in the Java version as they are in the Python version. I have a feeling that the Python 
 translation of the DOM API was actually done by sticking too closely to the Java version, and thereby being 
 unpythonic, which is a completely undefined term.

 Bill Venners: But you know it when you see it.

 Guido van Rossum: That's exactly the problem. I can't teach anyone else what makes a pythonic interface.

I think the definition of "unpythonic" is actually closest in spirit to the definition of "obscene". Nobody can define it but everybody thinks they know what it is when they see it. At its worst, I've seen people wield the term "unpythonic" as a stick to beat other people and technologies with (while of course having no other viable solution to the problem at hand). At its best, I've seen people wield the term to justify making small changes to things to make them easier to use. At the end of the day, I'd rather that people didn't use the term in public forums as if it was a well-understood concept, because it's pretentious and suggestive. Instead, just enumerate concretely what's wrong with the thing you're beating up with the "unpythonic" stick and suggest ways to fix it; you can skip the pretension.

Created by chrism
Last modified 2005-11-05 11:49 PM

Unpythonic == UnAmerican

I love it when people wield that one, especially in the media. It's a sure sign they are on shakey ground in their argument. I feel much the same way about "unpythonic". It's a great way to distance ones self intellectually. If something in Python itself is called "unpythonic" then you essentially can't use it as an argument against Python or using Python. Doing this, as has been done with lamba, map, DOM, etc., is a bit of a catch-22, however. There is no spec for Python save CPython itself. So if something in CPython is unpythonic (especially core parts of the language, like lambda or builtins), then by simple deduction we must conclude the Python itself is unpythonic. Of course this is pure rubbish, nothing is more pythonic then Python.

Taking things this literally, no matter how entertaining, is not really credible, however. I do think it demonstrates that there is something that defines Python beyond CPython. Of course this thing is not formalized anywhere, hence the need for this vague word to indicate exclusion from its prinicples. It's a really more about aesthetics than anything. Fashions come and go, and at one time functional programming was fashionable to pythonistas. Now it is not. Surely there are things currently considered pythonic that will one day be "so last Friday".

Python was simple

I think the term pythonic refers to python's simple, cohesive design. Meaning something doesn't look right (it doesn't fit into the general design and feel), it's not pythonic. That said, I think python is growing out of it's simplicity with some of its newer features, so pythonic won't mean much anymore.

1131325157

Is this a defensive post to Zope2 being always referenced as un-pythonic?

I'd say "Pythonic", while a broad term would be defined in:
The Zen of Python - http://python.org/peps/pep-0020.html
What is Pythonic? - http://faassen.n--tree.net/blog/view/weblog/2005/08/06/0
Style Guide for Python Code - http://python.org/peps/pep-0008.html

good points

These are good points. I wrote a weblog entry a while back trying to describe the meaning of "pythonic":

http://faassen.n--tree.net/blog/view/weblog/2005/08/06/0

prompted by someone asking what the heck it meant (probably as the result of a discussion where someone called
Zope not Pythonic, I suspect :).

I think the concept "Pythonic" still has value, no matter that it's hard to define. It only has limited value though,
and I agree it should not be used without further specification. This is a quote from my original entry:

"Sometimes I think the condemnation of software as 'unpythonic' may be somewhat unfair and may obscure other positive aspects of the software. A less powerful framework that is easy to pick up for a Python programmer may be considered more Pythonic than a far more powerful system that takes more of a time investment to learn."

"This code is not Pythonic" is not a very good argument
*by itself* to reject it. It could be a basis for further discussion. I do believe that as an abstract ideal the goal "I want my software to be Pythonic" can be useful to guide evolution to consensus idioms and patterns, even though, as Jeff says, there are vast differences between frameworks that all call themselves Pythonic.

I agree

I agree with your basic premise - that unpythonic code is obscene...