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

Chris Dutton chris at
Thu Oct 11 08:46:43 CEST 2001

in article slrn9s9h7p.1jk.huaiyu at, Huaiyu Zhu at
huaiyu at 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:

More information about the Python-list mailing list