Zen of Python “obvious way to do it” (was: [TSBOAPOOOWTDI]using names from modules)

Steve D'Aprano steve+python at pearwood.info
Sun Nov 5 04:18:47 EST 2017


On Sun, 5 Nov 2017 12:49 pm, Ben Finney wrote:

> Steve D'Aprano <steve+python at pearwood.info> writes:
> 
>> On Sun, 5 Nov 2017 06:42 am, Stefan Ram wrote:
>>
>> > What is the one way to do it?
>>
>> There is no philosophy of "one way to do it" in Python, that is a
>> misunderstanding (possibly deliberate...) spread about by Perl users,
>> to contrast Python from Perl's "more than one way to do it".
[...]

> I think the confusion is quite understandable, and that the Zen was
> written quite consciously referencing the (at the time quite well-known)
> Perl princple “There's more than one way to do it”.

I daresay you are right about the second part, but I'm not so sure about the
first.

Python supports both while and for loops, and recursion, and it is well known
than anything written recursively can be re-written using iteration (and vice
versa), and anything using a for-loop can be re-written using while (but not
vice versa). I don't think it is reasonable to give any credence to the idea
that Python allows "only one way" to solve problems.

Sure, it's easy to toss the phrase out without thinking, and I'm sure that in
my early years as a Python user I probably did exactly that.

I suppose that "people say things without thinking about them first" is a kind
of understanding, so I guess I'll have to admit that technically you are
right :-)


> So, I have given up trying to assign *blame* for that confusion. But
> from what I can tell it's a canard to say that the confusion is “spread
> about by Perl users”. 

Perhaps I should have said "*was*. I hardly see this "Only One Way" business
these days. A decade or two ago, it was much more common, and mostly (in my
experience) coming from Perl users as a put-down, that Python needlessly
limits what the programmer can do.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list