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

Michael Hudson mwh at python.net
Tue Nov 19 07:06:27 EST 2002


Alex Martelli <aleax at aleax.it> writes:

> Richard Dillingham wrote:
> 
> >> It's better written as:
> >>
> >> if coords[0]<=posx<=coords[2] and coords[1]<=posy<=coords[3]:
> > 
> > Hmm.... I just tried that, and am quite amazed to find that it actually
> > works.
> 
> Python comparison operators CHAIN -- a wonderful little trait...

Indeed they do.  There's a wonderful little wart, though.  What does
this:

if 1 in [1] < 2:
  print 1
else:
  print 2

print?

Cheers,
M.
(actually, the answer may be Python version dependent...)

-- 
  I hate leaving Windows95 boxes publically accessible, so shifting
  even to NT is a blessing in some ways.  At least I can reboot them
  remotely in a sane manner, rather than having to send them malformed
  packets.      -- http://bofhcam.org/journal/journal.html, 20/06/2000



More information about the Python-list mailing list