jstok at bluedog.apana.org.au
Fri Mar 17 20:38:14 CET 2000
Jeff Pinyan wrote in message ...
>I'll be a jerk, and do this brevity-style:
> while notDone:
> print ("Oh no!","Tjohoo")[this.getNumberOfSomething() == 10]
>Now, I ask you folk, is that "bad" Python? Is that "bad" programming in
>general, to be brief and succinct like that? I'm curious -- I have a
>tendency to do things like that. :)
Programming style guides advise one to make the logical structure of a
program explicit. That means if ... else blocks that can be read easily.
This, on the other hand, makes you think about it way too much. The
maintenance programmer that wants to add another condition is going to have
to rewrite the whole block.
It doesn't seem so obnoxious as a code fragment as it would in a 10,000 line
program, full of little tricks like this.
More information about the Python-list