[Tutor] a shorter way to write this

Sean Perry shaleh at speakeasy.net
Sat Mar 26 03:50:13 CET 2005

Smith, Jeff wrote:
> For all the talk of Python only having one way to do something which is
> why it's so much better than Perl, I've counted about 10 ways to do this
> :-)

Knowing you said this at least half in jest, I still feel the need to 

In any programming language, you have flexibility in how to define an 
algorithm. Think about how many different ways you can ask "is this 
string a in that string b?".

The Python motto is actually better stated: there is one obvious way and 
it is often the right one.

In the Python 1.5 days, choices were much fewer. With the new versions 
have come a more rich selection of features.

Python's "only one way" is often brought up as a counterpoint to Perls 
TIMTOWTDI. Remembering which Perl idiom is the right one, for the right 
situation *AND* matches the rest of the project can be a real nightmare. 
Not to mention that choosing the wrong one often kills your performance 
(-: This is a big reason why I stick to Python. We may have choices, but 
they are often clear and obvious once you know the language.

More information about the Tutor mailing list