assignment in control structure syntax (was Re: Curious assignment behaviour)

Chris Dutton chris at cmb-enterprises.com
Thu Oct 11 08:46:43 CEST 2001


in article slrn9s9h7p.1jk.huaiyu at gauss.almadan.ibm.com, Huaiyu Zhu at
huaiyu at gauss.almadan.ibm.com wrote on 10/10/01 6:00 PM:

> There are several other uses for this syntax.  For example,
> 
> if val = dict1[key1]; val:
> process1(val)
> elif val = dict2[key2]; val:
> process2(val)
> elif mylist += otherlist; len(mylist) > 4:
> process3(mylist)

The example I saw somewhere that I liked was

if something as x:
   do_something_to(x)




More information about the Python-list mailing list