Hmm... An idea: if a,b==c,d:

Grant Edwards grante at visi.com
Mon Nov 18 18:11:50 EST 2002


In article <YgeC9.17351$0U1.1712104 at news2.east.cox.net>, Richard Dillingham wrote:

>> > Kind of like we have multiple assignments in a line
>> > (oldx,oldy=x,y), what do you think of the ability to have
>> > multiple tests in an if statement with only one == or >=.
>> >
>> > This would mean that lines like the following:
>> > if posx>=coords[0] and posy>=coords[1] and posx<=coords[2] and
>> > posy<=coords[3]:
>> >
>> > Could be rewritten like so:
>> > if posx,posy>=coords[0],coords[1] and posx,posy<=coords[2],coords[3]
>>
>> How would you disambiguate that from a comparison of two tuples?

> It doesn't have ()s, so it ain't two tuples. Easy enough, da?

Not really...  ()s don't have anything particularly to do with
tuples.  The comma is the tupple constructor operator: a,c is a
tuple (a,c) is the same tuple with parens around it.

-- 
Grant Edwards                   grante             Yow!  My ELBOW is a remote
                                  at               FRENCH OUTPOST!!
                               visi.com            



More information about the Python-list mailing list