Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #48106 > unrolled thread
| Started by | Nick the Gr33k <support@superhost.gr> |
|---|---|
| First post | 2013-06-14 12:50 +0300 |
| Last post | 2013-06-15 16:28 +0300 |
| Articles | 2 on this page of 42 — 18 participants |
Back to article view | Back to comp.lang.python
Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-14 12:50 +0300
Re: Eval of expr with 'or' and 'and' within Fábio Santos <fabiosantosart@gmail.com> - 2013-06-14 11:03 +0100
Re: Eval of expr with 'or' and 'and' within Robert Kern <robert.kern@gmail.com> - 2013-06-14 11:14 +0100
Re: Eval of expr with 'or' and 'and' within Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-14 16:09 +0000
Re: Eval of expr with 'or' and 'and' within rusi <rustompmody@gmail.com> - 2013-06-14 09:21 -0700
Re: Eval of expr with 'or' and 'and' within Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-06-14 20:03 +0200
Re: Eval of expr with 'or' and 'and' within rusi <rustompmody@gmail.com> - 2013-06-14 11:37 -0700
Re: Eval of expr with 'or' and 'and' within Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-14 19:47 +0100
Re: Eval of expr with 'or' and 'and' within alex23 <wuwei23@gmail.com> - 2013-06-14 23:50 -0700
Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-15 10:04 +0300
Re: Eval of expr with 'or' and 'and' within Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-15 07:49 +0000
Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-15 10:59 +0300
Re: Eval of expr with 'or' and 'and' within Grant Edwards <invalid@invalid.invalid> - 2013-06-14 14:49 +0000
Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-14 18:16 +0300
Re: Eval of expr with 'or' and 'and' within Nobody <nobody@nowhere.com> - 2013-06-14 17:42 +0100
Re: Eval of expr with 'or' and 'and' within Grant Edwards <invalid@invalid.invalid> - 2013-06-14 19:30 +0000
Re: Eval of expr with 'or' and 'and' within Nobody <nobody@nowhere.com> - 2013-06-15 00:02 +0100
Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-15 10:57 +0300
Re: Eval of expr with 'or' and 'and' within Michael Torrie <torriem@gmail.com> - 2013-06-14 10:29 -0600
Re: Eval of expr with 'or' and 'and' within Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-14 16:49 +0000
Re: Eval of expr with 'or' and 'and' within Michael Torrie <torriem@gmail.com> - 2013-06-14 11:28 -0600
Re: Eval of expr with 'or' and 'and' within MRAB <python@mrabarnett.plus.com> - 2013-06-14 18:49 +0100
Re: Eval of expr with 'or' and 'and' within Chris Angelico <rosuav@gmail.com> - 2013-06-15 03:56 +1000
Re: Eval of expr with 'or' and 'and' within Grant Edwards <invalid@invalid.invalid> - 2013-06-14 19:33 +0000
Re: Eval of expr with 'or' and 'and' within Chris Angelico <rosuav@gmail.com> - 2013-06-15 09:56 +1000
Re: Eval of expr with 'or' and 'and' within Nobody <nobody@nowhere.com> - 2013-06-15 00:09 +0100
Re: Eval of expr with 'or' and 'and' within Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-15 01:34 +0000
Re: Eval of expr with 'or' and 'and' within Cameron Simpson <cs@zip.com.au> - 2013-06-15 12:03 +1000
NANs [was Re: Eval of expr with 'or' and 'and' within] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-15 04:22 +0000
Re: Eval of expr with 'or' and 'and' within Chris Angelico <rosuav@gmail.com> - 2013-06-15 12:21 +1000
Re: Eval of expr with 'or' and 'and' within Nobody <nobody@nowhere.com> - 2013-06-15 00:06 +0100
Re: Eval of expr with 'or' and 'and' within MRAB <python@mrabarnett.plus.com> - 2013-06-15 01:26 +0100
Re: Eval of expr with 'or' and 'and' within Benjamin Kaplan <benjamin.kaplan@case.edu> - 2013-06-14 09:47 -0700
Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-14 20:01 +0300
Re: Eval of expr with 'or' and 'and' within Robert Kern <robert.kern@gmail.com> - 2013-06-14 18:27 +0100
Re: Eval of expr with 'or' and 'and' within Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-06-14 22:05 +0300
Re: Eval of expr with 'or' and 'and' within Grant Edwards <invalid@invalid.invalid> - 2013-06-14 19:36 +0000
Re: Eval of expr with 'or' and 'and' within Cameron Simpson <cs@zip.com.au> - 2013-06-15 10:14 +1000
Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-15 11:20 +0300
Re: Eval of expr with 'or' and 'and' within Lele Gaifax <lele@metapensiero.it> - 2013-06-15 11:48 +0200
Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-15 16:24 +0300
Re: Eval of expr with 'or' and 'and' within Nick the Gr33k <support@superhost.gr> - 2013-06-15 16:28 +0300
Page 3 of 3 — ← Prev page 1 2 [3]
| From | Nick the Gr33k <support@superhost.gr> |
|---|---|
| Date | 2013-06-15 16:24 +0300 |
| Message-ID | <kphpu2$slt$2@news.ntua.gr> |
| In reply to | #48276 |
On 15/6/2013 12:48 μμ, Lele Gaifax wrote:
> Nick the Gr33k <support@superhost.gr> writes:
>> but those 2 gives the same results back
>>
>> "k" in (name+month+year) == "k" in (name and month and year)
>> True
>>
>> so both seem to work as expected.
>
> That happens only by chance: it seems you now understand the evaluation
> of "boolean" expressions in Python, so the following should be clear to
> you:
>
>>>> "k" in ("there" + "is" + "a" + "k" + "character" + "somewhere")
> True
ALL strings in the parenthesis are being concatenated to a BIG string,
like ('k' in BIG_string) which returns the Boolean value of True since
'k' is contained within it.
>>>> "k" in ("there" and "is" and "a" and "k" and "character" and "somewhere")
> False
first the expression of the parenthesis evaluation.
The argument being returned from ("there" and "is" and "a" and "k" and
"character" and "somewhere") expresssion, is the one that is responsible
for the determination of the expression's evaluation.
That would be the last argument, string "somewhere" because:
1. All previous strings before the last one were found truthies, so it
was turn of the last one to be evaled too.
2. Since "somewhere" is a truthy of course for being a non-empty string
then ALL arguments of the expression are found TRUE which results for
the expression to stand TRUE.
3. What determined the expression to stand TRUE was the evaluation of
the last argument "somewhere", so the latter was the key factor for that
to happen, hence its being returned back as a result(thats how Python works)
4. so it's like checking if ('k' in "somewhere") which return the
Boolean value of False since the aforementioned char isn't contained in
the aforementioned string.
--
What is now proved was at first only imagined!
[toc] | [prev] | [next] | [standalone]
| From | Nick the Gr33k <support@superhost.gr> |
|---|---|
| Date | 2013-06-15 16:28 +0300 |
| Message-ID | <kphq5g$slt$3@news.ntua.gr> |
| In reply to | #48276 |
On 15/6/2013 12:48 μμ, Lele Gaifax wrote: >> but those 2 gives the same results back >> >> "k" in (name+month+year) == "k" in (name and month and year) >> True >> >> so both seem to work as expected. > That happens only by chance: it seems you now understand the evaluation > of "boolean" expressions in Python, so the following should be clear to > you: yes indeed! if we had questioned python for: "k" in (name and year and month) that would have returned the argument month back which is "efgh" and then the if would have evaled to false since 'k' isn't part of the latter. "k" in (name and month and year) != "k" in (name and year and month) As wee see, the order of the arguments in an expression matters. -- What is now proved was at first only imagined!
[toc] | [prev] | [standalone]
Page 3 of 3 — ← Prev page 1 2 [3]
Back to top | Article view | comp.lang.python
csiph-web