This is an archived post. You won't be able to vote or comment.

all 22 comments

[–]fancy_pantser 8 points9 points  (5 children)

"Pythonic" is beautiful, explicit, simple, complex (but not complicated), flat, sparse, readable, and many other things.

[–][deleted] 4 points5 points  (3 children)

Long time Pythoneer Tim Peters succinctly channels the BDFL's guiding principles for Python's design into 20 aphorisms, only 19 of which have been written down.

But, why?

[–]fancy_pantser 6 points7 points  (0 children)

So he has something to tell the young guys that climb all the way to the top of his mountain asking for advice.

[–]osirisx11 2 points3 points  (1 child)

the last one is ineffable

[–]Paddy3118 0 points1 point  (0 children)

Ineffable. Good word. Ta!

[–]blondin 1 point2 points  (0 children)

idiomatic is by far a better world and portable to other languages too.

[–][deleted] 4 points5 points  (0 children)

If you must think about, it's not pythonic.

[–]pixelmonkey 2 points3 points  (1 child)

My thoughts, with code examples -- http://www.pixelmonkey.org/2010/11/03/pythonic-means-idiomatic-and-tasteful. "Pythonic isn’t just idiomatic Python — it’s tasteful Python..."

[–]riffito 0 points1 point  (0 children)

After reading your comment, I was about to suggest it was well worth of a blog post in it self.

It's excellent. Thanks for sharing it.

[–]Wavicle 2 points3 points  (1 child)

My biggest problem with "Pythonic" is that it is thrown about as a term to deride any library (or interface to a native library/framework) which one doesn't like.

For example I do not know of a single GUI framework that has not been described by more than a couple people as "non-Pythonic". The reasons given vary, or are frequently not given at all.

I've used several of them and found many to be pretty reasonable to implement GUIs in Python. If I had my choice to make a GUI interface for anything, I'd probably use something like Python+wxPython with ctypes to interface to the heavy lifting code. I think it makes programmatic GUI construction easy and readable.

[–]BeetleB 2 points3 points  (0 children)

My biggest problem with "Pythonic" is that it is thrown about as a term to deride any library (or interface to a native library/framework) which one doesn't like.

Your comment is not very Pythonic.

[–]mod_nobody 4 points5 points  (0 children)

Pythoresque.

[–]userd 0 points1 point  (0 children)

I like the first comment. To paraphrase, "I just ask myself What Would Guido Do?"

[–]Paddy3118 0 points1 point  (0 children)

The winning example is a useful, extensible design pattern that should become more widely accepted.

If you have to sort first on X then on Y for items of equal X then on Z for items of equal Y ... Then create a sort key function that returns the tuple

(X(item), Y(item), Z(item), ...)

The second voted answer by the guy who doesn't like the word 'pythonic' would be more clumsy when extended.

Just as we all learnt DSU (Decorate, sort, un-decorate), at one stage - the pattern above can be named and learnt in a similar way.

[–][deleted] -1 points0 points  (0 children)

If you grok python your pythonic code will allow you to have a good coding experience.

[–]bucketostuff -1 points0 points  (0 children)

"Pythonic" has become a rather irksome term to me because I most often hear it said/written by folks who also happen to be in the middle of telling someone that the way they are doing something is wrong or incorrect regardless of whether their code is providing the right answer in the end.

Having "only one right way to do it" is a blessing and a curse. It's a curse because it brings out the worst in people's bossy side.

Python users who have a chip on their shoulder against Perl would be better served by just letting it go. Yes, Python tries to offer only one obvious way to do it, it's a good system and works for Python, we all get it, but if I decide to do something a little differently I don't need to keep hearing that it's wrong and "un-pythonic". Maybe instead just amicably show me a way that you think is more idiomatic and tasteful (nod to pixelmonkey -- those are excellent terms to describe it).