Python IF THEN chain equivalence

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Thu Nov 13 19:33:06 EST 2008


jzakiya:
> I asked a very narrow question about a very specific language
> mechanism, and I know exactly what and why I'm doing what I'm doing.

You are of course free to use Python as you want. And probably some of
the answers weren't fully polite.
But it's interesting to see why they have given such answers. While
your code can be fit for Forth or assembly, it may be unfit, in its
current form, for the usual practices of Python programming (or C#/
Java programming, etc). In high-level languages large trees of very
nested ifs are seen as error-prone, not much readable, brittle... So
some alternative solutions are often used (even if they may be a
little slower).
If you need speed you may use Psyco too.

Bye,
bearophile



More information about the Python-list mailing list