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

Cliff Wells LogiplexSoftware at earthlink.net
Mon Nov 18 17:42:04 EST 2002


On Mon, 2002-11-18 at 13:49, 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]

One problem is that this syntax already has a meaning (although it
doesn't appear to have the meaning you seem to intend):

Python 2.2.1 (#1, Aug 30 2002, 12:15:30)
[GCC 3.2 20020822 (Red Hat Linux Rawhide 3.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> x, y = 2, 1
>>> x1, y1 = 1, 2
>>> (x, y) > (x1, y1)
1
>>>

The other, greater problem is that you are using a *specific*
application of tuples (coordinates) and in general the meaning you
desire can't be applied to tuples, so a language change is undesirable.

Consider that when interpreting tuples as coordinates, (1,2) == (2,1) is
probably true since the magnitudes of the vectors are equal (this would
be a common interpretation for comparing coordinates), but would
probably be considered false for most other applications of tuples.
	
You'll probably be better off creating a Coordinate() class that has the
meaning you are looking for, or perhaps search Google to see if someone
else already has.


-- 
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/57fe3599/attachment.sig>


More information about the Python-list mailing list