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

Cliff Wells LogiplexSoftware at earthlink.net
Mon Nov 18 19:44:08 EST 2002


On Mon, 2002-11-18 at 15:31, Richard Dillingham wrote:
> if a,b>c,d: print a
>   File "<input>", line 1
>     if a,b>c,d: print a
>         ^
> SyntaxError: invalid syntax
> 
> > Consider that when interpreting tuples as coordinates, (1,2) == (2,1) is
> probably true since...
> 
> That's not what I want at all, either. 1,2 == 2,1? Eh? Uh. That's not the
> same point.

It would depend upon how you look at it.  They have the same absolute
value (i.e. their distance from (0, 0)).  Hence if you were to define
comparison operators for coordinates (which might be used in sorting,
for instance) this is a perfectly valid assumption (otherwise is (2,1) >
(1,2)?).

> I'm temporarily storing mouse coordinates and comparing with old ones to
> determine why I seem to be getting the mouse moved mesage when the mouse
> coordinates haven't actually changed yet, among other things (In PyGame). I
> was just thinking that the if statement would be shorter and still
> understandable if done using commas, like assignment can be. That's all.

In that case, it seems you only need to know if they are the same point,
not whether one is "greater than" the other (your example of a,b>c,d is
misleading in this respect).  I would just use

if (a,b) != (c,d):
    # mouse moved
    ...


-- 
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308  (800) 735-0555 x308
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20021118/406b1cfa/attachment.sig>


More information about the Python-list mailing list