if/elif chain with assignment expressions
donn at drizzle.com
Mon Jul 12 07:33:00 CEST 2004
Quoth Fernando Perez <fperez528 at yahoo.com>:
| Well, the problem here (and apparently others share this opinion) is that this
| particular restriction genuinely forces kludgy code in certain circumstances.
| As John Roth pointed out, the looping case is easily solved with iterators, but
| Paul's original one is not.
| I know that the if(x=0) bug in C/C++ is a potentially nasty one, having been
| bitten by it myself in the past. It is also true that having this particular
| option available allows certain kinds of code to be written in a clear and
| concise manner. So yes, it is a slightly dangerous feature, but one which
| offers true expressive power. Hence my characterization of it as 'training
| wheels': I don't mean to say that only beginners can fall into the trap (even
| Lance Armstrong can fall off a bike), but rather that experienced users will
| know what to watch for, and will be willing to pay the price of potentially
| falling for the liberty of going faster :)
I know people who would like this feature a lot, if it existed in
Python and if they wrote in Python. I know this from their C code,
which I have had miserable occasion to deal with. If what we get
is kludgy code, I accept that gladly in return for the guarantee
that I shall never have to deal with this kind of mess in Python.
Donn Cave, donn at drizzle.com
More information about the Python-list