To an extent greater than some other languages, Python developers focus on the pythonic way:

Python has a particularly strong idiom built around the idea that, "there should be one—and preferably only one—obvious way to do it".

Here are some recent, well-received questions that illustrate the issue. If these appeared in other language tags, I suspect that they would be quickly closed.

Requests for "the best way" are necessarily opinion-based, but since the topic is a core feature of the language, do such requests fall in the "Good Subjective" category or should they be closed as "primarily opinion-based?" Is there a known metric to determine the pythonicity of code beyond community consensus?

  • 3
    I think the keyword in that quote is idea. Is it that way in practice though? The answers to these questions look very code golfish.
    – animuson StaffMod
    Commented Aug 2, 2013 at 20:40
  • 3
    Good topic for discussion, and nice to see a discussion post that isn't a thinly-disguised heres-what-im-outraged-about-dont-you-agree.
    – jscs
    Commented Aug 2, 2013 at 20:52
  • @animuson It's part of the Zen of Python - included in the interpreter itself. It's very much in mind when the developers make modifications to the language. The important part is that it's only preferred for there to be only one (obvious) way to do something, so sometimes there are several Pythonic answers. Commented Aug 2, 2013 at 21:01
  • yes. imho import this has many of the aspects of a poem; and poems are subjective ;) Commented Aug 2, 2013 at 21:01
  • 1
    Good question, although this isn't exactly limited to Python. Programming to conform to the language's idioms also comes up in other languages as well, although Python programmers seem to be the only ones that have come up with a catchy word for it.
    – user200500
    Commented Aug 2, 2013 at 21:06
  • There are a ton of "perlish" questions, too.
    – Steve P.
    Commented Aug 2, 2013 at 21:07
  • Ruby programmers rarely focus on doing things the Pythonic way, but Ruby is far more notorious for being "opinionated" and trying to force developers to do things the "right" way than Python is. You should get this notion out of your head that Python developers follow patterns more than other programmers, just because they branded it better.
    – djechlin
    Commented Aug 2, 2013 at 21:08
  • 3
    Good question -- I've always been irritated by the "most Pythonic" questions, especially when they show no effort and still get wildly upvoted. Commented Oct 22, 2013 at 16:52
  • In the first example, the OP has removed all references to pythonic. Remove? Commented Mar 16, 2014 at 15:48
  • @PeterMortensen Good catch. Done. Commented Mar 16, 2014 at 16:13
  • Would it be appropriate to recommend Code Review these days?
    – Barmar
    Commented Mar 23, 2020 at 23:18

3 Answers 3


A little troubling, that the first question could be considered too basic/trivial if it weren't for the words Pythonic - "What is the best way to parse a string that has a number and other characters to an int?"

And perhaps, that is the best litmus test - is it still a good and interesting question without the Pythonic criteria? Because really, all it should imply is simplicity and clarity (etcetera).

A secondary criteria could be the requested outcome (shortest running time, fewer characters, cleaner syntax), which would at least help point out those that are just playing code golf, or asking for code review.

That said, I have a ton of sympathy for people trying to keep their code clean and useful, and I do believe that some well-defined instances should fall under the domain of Stack Overflow (i.e. is there already a function that does this).


As usual, the answer is "is it a good question anyway?"

  • The first example you gave I voted to close as off topic:

    Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results.

  • The second is a little disorganized but a good question. The OP had some intuition there was a better way to do it and asked if there was, after documenting what she tried.

  • Third question is also off topic for same reason as first.

You're getting at a harder question of "Is it okay for someone to ask a better way to do something, even if they have a working way?" to which the answer is, generally, yes. But the examples you gave don't quite raise this question - they were either very bad questions or decent questions without even having to get into this new debate.

  • 1
    I'd personally have gone with primarily opinion based for the first one, since I think the question isn't exactly "how do I parse numbers out of a string", but rather, "what approach to parsing numbers out of a string would please the Old Gods of Python the most"?
    – user200500
    Commented Aug 2, 2013 at 21:23
  • @Asad in this case I think so, but I think off topic is a stronger fit. It's not really clear there is a canonical (which is what pythonic means to those lacking python hubris) solution, so it's silly to ask for one.
    – djechlin
    Commented Aug 2, 2013 at 21:25

Yes, unfortunately. I have a hard time finding anything that ends with 'ic' to be an objective topic. Because whether or not a qualitative characteristic belongs to a certain class is a question without a 'right' answer necessarily.

  • I disagree, per my answer.
    – djechlin
    Commented Aug 3, 2013 at 20:36
  • my answer: "Are “Pythonic” questions opinion-based?": yes. I am not talking about the linked question, I'm answering the topic. Commented Aug 3, 2013 at 20:38
  • This question is asking if the method is pythonic and I do not find to be overly opinion based: stackoverflow.com/questions/18024503/lambda-args-kwargs-none/… please revise your answer to explain why questions like this are problematic, or explain which questions your answer applies to, and I will reconsider my downvote.
    – djechlin
    Commented Aug 3, 2013 at 20:48
  • Do as you wish. As it stands this is a fairly poor answer based on your vote count, but it could be a good answer in the eyes of the community if you took feedback. But if you don't care, that's fine, I hope you enjoy your time posting here.
    – djechlin
    Commented Aug 3, 2013 at 22:12
  • Sounds like there's a need for a new SE site (if there isn't one already) for Pythonicity questions.
    – RobH
    Commented Oct 22, 2013 at 16:51

Not the answer you're looking for? Browse other questions tagged .