[Tutor] trouble with function-- trying to check

Terry Carroll carroll at tjc.com
Wed Mar 14 19:15:47 CET 2007


On Wed, 14 Mar 2007, Kent Johnson wrote:

> This has already been discussed on this thread. == and 'in' are comparisons.

Aha.  I did not see this discussion in the thread; the closest thing I
noticed was Alan's note that I was riffing from, which concluded with "It
definitely seems to work as I explained it but how it works is defeating
my befuddled brain right now."  Looking through the archives, I now find
your note.

> (c == c in 'crab')
> means
> (c == c) and (c in 'crab')
> 
> http://docs.python.org/ref/comparisons.html

Thanks.  My take-away from this is that comparisons (including "in", which
would not have intuitively struck me as a comparison) don't have
precedence rules, so that you can chain them.  It just looks odd to chain
an "=="  with an "in", but I guess it's legal.



More information about the Tutor mailing list