if/elif chain with assignment expressions

Neil Hodgson nhodgson at bigpond.net.au
Sun Jul 11 20:10:30 EDT 2004


Fernando Perez:

> In general I applaud python's efforts for being clear, readable,
> and not error-prone.  But this is one of those cases where leaving
> the training wheels on causes genuine grief (I have in the past
> many times run into the example you mentioned, and have cursed
> it silently).

   I hope this does not change as it makes analysis of the code easier.
Reading and understanding code is as important as writing it. Analysis of a
problem depends as much on restricting the set of possible causes ('it is
*not* the case that') as it does on generating a larger set of possible
causes ('it is the case that'). Pruning the possible cause tree is extremely
valuable and Python cooperates with a well thought out set of restrictions.
Being able to depend on the absence of assignments in if and while
statements is a benefit when fixing Python code over C/C++. Characterizing
these as "training wheels" and thus only of use to beginners is
unreasonable.

   Neil





More information about the Python-list mailing list