python idioms : some are confusing

Chris Rebert clp2 at rebertia.com
Fri Sep 21 02:04:11 EDT 2012


On Thu, Sep 20, 2012 at 10:34 PM, Vineet <vineet.deodhar at gmail.com> wrote:
> Amongst the python idioms, how the below-mentioned make sense?

These aren't idioms (that term has a specific technical meaning in
programming); they're *way* too abstract to be idioms. "Design
principles" or "design guidelines" would be a better description.

> ## 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.
>
> --- In programming, there can be a number of ways, equally efficient, to do certain  thing.

Yes, but that brings with it the cost of having to understand/learn
them all, because you'll encounter them when
reading/maintaining/modifying others' code. And you'll have to
evaluate them all to choose which one you should use (which might even
vary from moment to moment depending on the circumstances). And you'll
have to watch out for subtle variants that actually do something
significantly different. Better to keep things simple in the X% of
cases where the differences don't matter enough, and save those brain
cycles for other, more important things.

See also: the so-called "paradox of choice".
Further reading: the criticisms on
http://c2.com/cgi/wiki?ThereIsMoreThanOneWayToDoIt

> ## Although never is often better than *right* now.
>
> --- How come "never" is better that "right now" ?

Because "right now" is so quick that it was likely hastily hacked
together and thus of poor (or at least lesser) quality.

Cheers,
Chris



More information about the Python-list mailing list