Is vars() the most useless Python built-in ever?
Ben Finney
ben+python at benfinney.id.au
Tue Dec 1 20:47:40 EST 2015
Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:
> You misunderstand the koan.
>
> "There should be one way to do it" does not prohibit more than one
> way.
Further, that's omitting a very important modifier from the koan.
Even without the parenthetical, the koan reads:
There should be one obvious way to do it.
So yes, there can certainly be multiple ways to do it. But it's very
important that there be one *obvious* way.
In other words: Don't present the user with a multitude of options with
no *obvious* choice for those who don't care (yet) to learn about the
choice. Make one of them *obvious* so that's the usually-correct choice.
> (Although having multiple redundant ways is discouraged.) The koan
> exists to encourage the existence of *at least* one (but preferably
> only one) way to do it.
And the Pythonic approach is to make an *obvious* way to do it. As you
say, ‘print’ is that one obvious way for emitting simple text output.
--
\ “What's another word for Thesaurus?” —Steven Wright |
`\ |
_o__) |
Ben Finney
More information about the Python-list
mailing list