Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Eval of expr with 'or' and 'and' within Date: Fri, 14 Jun 2013 14:49:41 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 51 Message-ID: References: NNTP-Posting-Host: dsl.comtrol.com X-Trace: reader1.panix.com 1371221381 24590 64.122.56.22 (14 Jun 2013 14:49:41 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Fri, 14 Jun 2013 14:49:41 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) Xref: csiph.com comp.lang.python:48158 On 2013-06-14, Nick the Gr33k wrote: > I started another thread no kidding. > because the last one was !@#$'ed up by irrelevant replies and was > difficult to jeep track. > > >>> name="abcd" > >>> month="efgh" > >>> year="ijkl" > > >>> print(name or month or year) > abcd > > Can understand that, it takes the first string out of the 3 strings > that has a truthy value. Yes, it does. That's the way the language is defined to work. If you don't like it, pick a different language. > >>> print("k" in (name and month and year)) > True > > No clue. since the expression in parenthesis returns 'abcd' No it doesn't. Try it: Python 2.7.3 (default, Mar 20 2013, 14:16:24) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> name="abcd" >>> month="efgh" >>> year="ijkl" >>> >>> "k" in (name and month and year) True >>> (name and month and year) 'ijkl' >>> > how can 'k' contained within 'abcd' ? It doesn't -- Grant Edwards grant.b.edwards Yow! Am I having fun yet? at gmail.com