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

Andrew Koenig ark at research.att.com
Mon Nov 18 17:31:35 EST 2002


Richard> Kind of like we have multiple assignments in a line (oldx,oldy=x,y), what do
Richard> you think of the ability to have multiple tests in an if statement with only
Richard> one == or >=.

It is already possible to do this:

        a, b, c, d = 3, 4, 3, 4
        if (a, b) == (c, d):
                print "Equal"

Richard> This would mean that lines like the following:
Richard> if posx>=coords[0] and posy>=coords[1] and posx<=coords[2] and
Richard> posy<=coords[3]:

Richard> Could be rewritten like so:
Richard> if posx,posy>=coords[0],coords[1] and posx,posy<=coords[2],coords[3]

(a, b) >= (c, d) is already defined, but not in the way you suggest.

You are suggesting that (a, b) >= (c, d) be defined as (a>=c and b>=d),
but under that definition, >= would not be an order relation.

Instead, (a, b) >= (c, d) is defined as (a>c or (a==c and b>=d)).

-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark



More information about the Python-list mailing list