Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!news2.arglkargh.de!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.134.4.91.MISMATCH!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'operator': 0.03; 'charset:iso-8859-7': 0.04; 'interpreter': 0.05; 'string.': 0.05; 'detect': 0.07; 'string': 0.09; 'url:activestate': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; '>>': 0.16; "'-'": 0.16; 'nick': 0.16; 'over:': 0.16; 'run:': 0.16; 'year)': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'value.': 0.19; 'seems': 0.21; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'this?': 0.23; '>>>': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'character': 0.29; 'url:code': 0.29; 'returned': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '>>>>': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'this.': 0.32; 'run': 0.32; 'open': 0.33; 'cases': 0.33; 'received:209.85': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'replies': 0.36; 'returning': 0.36; 'doing': 0.36; 'received:209': 0.37; 'skip:& 10': 0.38; 'that,': 0.38; 'explain': 0.39; 'how': 0.40; 'read': 0.60; 'expression': 0.60; 'is.': 0.60; 'skip:y 20': 0.60; 'first': 0.61; 'name': 0.63; 'within': 0.65; 'here': 0.66; 'answer:': 0.84; 'subject:gets': 0.84; 'to:addr:support': 0.84; 'examine': 0.93; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Z5tS4Q/Z5g0GVKU7aDGdW/EZydGadlWCL0c2gQHLY+Y=; b=KoNv2/yX78eJtBNrzO5YarN+0FjPV4uaAJ0LjhE5zTE1wKNPQJ1dR6ZVhLCEDTiEst sFvijrJxkryg5kKCgV9EEdgNFcRmAc0UETSvD1/b4Nc9BZo5oxPfGKQ9OmAvoE/d2VTC /NTTbvxUd3tcYNAz0UY35CctPx8fl3+aCTsRXZ5+u5Bj4kjyTrLVHK+kKmZ7mvILNOI0 edrIQgWg1OkxoS72rKc4CoDok89qOoLWZrqezDOxycL8IeznXsAKzWyre8V+qsCPyrfD 4a/CYi28Rn+SKTbtyjRga/gavPzXhYv6xndTHO7HXM3fAswtVjJrQDHeROleUaU1RbjC TPOg== MIME-Version: 1.0 X-Received: by 10.224.106.195 with SMTP id y3mr1130939qao.35.1371200702896; Fri, 14 Jun 2013 02:05:02 -0700 (PDT) In-Reply-To: References: <2bc90d3b-09c2-4315-9357-ff7f039465e0@googlegroups.com> <51b926a3$0$29997$c3e8da3$5496439d@news.astraweb.com> <51ba6e92$0$29997$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 14 Jun 2013 10:05:02 +0100 Subject: Re: A certainl part of an if() structure never gets executed. From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: =?ISO-8859-7?B?zenq/Ovh7/Igyu/98eHy?= Content-Type: multipart/alternative; boundary=20cf3074b33acfe03a04df198a4a Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 163 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371200712 news.xs4all.nl 15970 [2001:888:2000:d::a6]:49536 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48096 --20cf3074b33acfe03a04df198a4a Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: quoted-printable On 14 Jun 2013 09:56, "Nick the Gr33k" wrote: > > On 14/6/2013 11:03 =F0=EC, Nick the Gr33k wrote: >> >> On 14/6/2013 4:14 =F0=EC, Steven D'Aprano wrote: >>> >>> On Thu, 13 Jun 2013 17:26:18 +0300, =CD=E9=EA=FC=EB=E1=EF=F2 =CA=EF=FD= =F1=E1=F2 wrote: >>> >>>> i just want 4 cases to examine so correct execute to be run: >>>> >>>> i'm reading and reading and reading this all over: >>>> >>>> if '-' not in ( name and month and year ): >>>> >>>> and i cant comprehend it. >>> >>> >>> Don't just read it. Open the interactive interpreter and test it. >>> >>> name =3D "abcd" >>> month =3D "efgh" >>> year =3D "ijkl" >>> >>> print(name and month and year) >>> >>> If you run that, you will see what the result of >>> (name and month and year) is. Now, ask yourself: >>> >>> "k" in (name and month and year) >>> >>> True or false? Check your answer: >>> >>> print("k" in (name and month and year)) >> >> >> >> >>> name=3D"abcd" >> >>> month=3D"efgh" >> >>> year=3D"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. >> >> >>> print("k" in (name and month and year)) >> True >> >> No clue. since the expression in parenthesis returns 'abcd' how can 'k' >> contained within 'abcd' ? >> >> >>> print(name and month and year) >> ijkl >> >> Seems here is returning the last string out of 3 strings, but have no >> clue why Python doing this. >> >> >>> print("k" in (name and month and year)) >> True >> >>> >> >> yes, since expression returns 'ijkl', then the in operator can detect >> the 'k' character within the returned string. >> > > Someone want to explain this? At the very least read the replies to your questions. http://code.activestate.com/lists/python-list/644572/ --20cf3074b33acfe03a04df198a4a Content-Type: text/html; charset=ISO-8859-7 Content-Transfer-Encoding: quoted-printable


On 14 Jun 2013 09:56, "Nick the Gr33k" <support@superhost.gr> wrote:
>
> On 14/6/2013 11:03 =F0=EC, Nick the Gr33k wrote:
>>
>> On 14/6/2013 4:14 =F0=EC, Steven D'Aprano wrote:
>>>
>>> On Thu, 13 Jun 2013 17:26:18 +0300, =CD=E9=EA=FC=EB=E1=EF=F2 = =CA=EF=FD=F1=E1=F2 wrote:
>>>
>>>> i just want 4 cases to examine so correct execute to be ru= n:
>>>>
>>>> i'm reading and reading and reading this all over:
>>>>
>>>> if '-' not in ( name and month and year ):
>>>>
>>>> and i cant comprehend it.
>>>
>>>
>>> Don't just read it. Open the interactive interpreter and t= est it.
>>>
>>> name =3D "abcd"
>>> month =3D "efgh"
>>> year =3D "ijkl"
>>>
>>> print(name and month and year)
>>>
>>> If you run that, you will see what the result of
>>> (name and month and year) is. Now, ask yourself:
>>>
>>> "k" in (name and month and year)
>>>
>>> True or false? Check your answer:
>>>
>>> print("k" in (name and month and year))
>>
>>
>>
>> =A0>>> name=3D"abcd"
>> =A0>>> month=3D"efgh"
>> =A0>>> year=3D"ijkl"
>>
>> =A0>>> print(name or month or year)
>> abcd
>>
>> Can understand that, it takes the first string out of the 3 string= s that
>> has a truthy value.
>>
>> =A0>>> print("k" in (name and month and year))<= br> >> True
>>
>> No clue. since the expression in parenthesis returns 'abcd'= ; how can 'k'
>> contained within 'abcd' ?
>>
>> =A0>>> print(name and month and year)
>> ijkl
>>
>> Seems here is returning the last string out of 3 strings, but have= no
>> clue why Python doing this.
>>
>> =A0>>> print("k" in (name and month and year))<= br> >> True
>> =A0>>>
>>
>> yes, since expression returns 'ijkl', then the in operator= can detect
>> the 'k' character within the returned string.
>>
>
> Someone want to explain this?

At the very least read the replies to your questions. http://code.act= ivestate.com/lists/python-list/644572/

--20cf3074b33acfe03a04df198a4a--