Why is "while" ticking me off???

Huaiyu Zhu hzhu at users.sourceforge.net
Fri Oct 6 15:34:25 EDT 2000


On Fri, 06 Oct 2000 18:14:01 GMT, Rainer Deyke <root at rainerdeyke.com> wrote:
>
>for key, dict, process in [(key1, dict1, process1), (key2, dict2,
>process2),\
>  (key3, dict3, process3), ...]:
>  val = dict[key]
>  if val:
>    process(val)
>    break

You could use this argument for the elimination of elif, I think. :-)

Here's a more hetrogeneous example:

if a = dict1[k1]; a:
    a.do_something_interesting()
elif a = k2.result(); a<0:
    print "Why is a = %s?" % a
elif a = generator(k3); a.startwith("icecream"):
    a = eat_it(a).left()
else:
    raise "I didn't know this could happen!"
print "I got it", a


What's the simplest way to do it in Python?  Does it look cleaner?

Maybe this is a good idea for a PEP?


Huaiyu



More information about the Python-list mailing list