[Tutor] “has a value of True” versus “evaluates true” (was: don't understand iteration)

2014-11-10 Thread Ben Finney
"Clayton Kirkwood"  writes:

> Also of confusion, the library reference says:
>
> Match objects always have a boolean value of True. Since match() and
> search() return None when there is no match, you can test whether there was
> a match with a simple if statement:
>
> match = re.search(pattern, string)
> if match:
> process(match)

The documentation is incorrect, as you point out: “have a boolean value
of True” implies that the value is identical to the built-in ‘True’
constant, which is never the case for these objects.

Instead, the passage above should say “evaluates true in a boolean
context”.

Would you be so kind as to report a bug to that effect
http://bugs.python.org/>?

-- 
 \   “The Vatican is not a state.… a state must have people. There |
  `\are no Vaticanians.… No-one gets born in the Vatican except by |
_o__)an unfortunate accident.” —Geoffrey Robertson, 2010-09-18 |
Ben Finney

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] “has a value of True” versus “evaluates true” (was: don't understand iteration)

2014-11-10 Thread Clayton Kirkwood
I reported it. I feel all grown up now. Kind of like one of the boys(girls...)

Clayton:<)


>-Original Message-
>From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On
>Behalf Of Ben Finney
>Sent: Monday, November 10, 2014 3:24 PM
>To: tutor@python.org
>Subject: [Tutor] “has a value of True” versus “evaluates true” (was:
>don't understand iteration)
>
>"Clayton Kirkwood"  writes:
>
>> Also of confusion, the library reference says:
>>
>> Match objects always have a boolean value of True. Since match() and
>> search() return None when there is no match, you can test whether
>> there was a match with a simple if statement:
>>
>> match = re.search(pattern, string)
>> if match:
>> process(match)
>
>The documentation is incorrect, as you point out: “have a boolean value
>of True” implies that the value is identical to the built-in ‘True’
>constant, which is never the case for these objects.
>
>Instead, the passage above should say “evaluates true in a boolean
>context”.
>
>Would you be so kind as to report a bug to that effect
>http://bugs.python.org/>?
>
>--
> \   “The Vatican is not a state.… a state must have people. There |
>  `\are no Vaticanians.… No-one gets born in the Vatican except by |
>_o__)an unfortunate accident.” —Geoffrey Robertson, 2010-09-18 |
>Ben Finney
>
>___
>Tutor maillist  -  Tutor@python.org
>To unsubscribe or change subscription options:
>https://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] “has a value of True” versus “evaluates true” (was: don't understand iteration)

2014-11-10 Thread wesley chun
good catch, and definitely a distinction beginners should be more cognizant
of.

it's also good to recognize that a call to "bool(match)" would render that
statement correct, as the built-in/factory function will return what an
object evaluates to (True [re.match object] or/vs.False [None]).

On Mon, Nov 10, 2014 at 5:31 PM, Clayton Kirkwood 
wrote:

> I reported it. I feel all grown up now. Kind of like one of the
> boys(girls...)
>
> Clayton:<)
>
>
> >-Original Message-
> >From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On
> >Behalf Of Ben Finney
> >Sent: Monday, November 10, 2014 3:24 PM
> >To: tutor@python.org
> >Subject: [Tutor] “has a value of True” versus “evaluates true” (was:
> >don't understand iteration)
> >
> >"Clayton Kirkwood"  writes:
> >
> >> Also of confusion, the library reference says:
> >>
> >> Match objects always have a boolean value of True. Since match() and
> >> search() return None when there is no match, you can test whether
> >> there was a match with a simple if statement:
> >>
> >> match = re.search(pattern, string)
> >> if match:
> >> process(match)
> >
> >The documentation is incorrect, as you point out: “have a boolean value
> >of True” implies that the value is identical to the built-in ‘True’
> >constant, which is never the case for these objects.
> >
> >Instead, the passage above should say “evaluates true in a boolean
> >context”.
> >
> >Would you be so kind as to report a bug to that effect
> >http://bugs.python.org/>?
> >
> >--
> > \   “The Vatican is not a state.… a state must have people. There |
> >  `\are no Vaticanians.… No-one gets born in the Vatican except by |
> >_o__)an unfortunate accident.” —Geoffrey Robertson, 2010-09-18 |
> >Ben Finney
> >
> >___
> >Tutor maillist  -  Tutor@python.org
> >To unsubscribe or change subscription options:
> >https://mail.python.org/mailman/listinfo/tutor
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A computer never does what you want... only what you tell it."
+wesley chun <http://google.com/+WesleyChun> : wescpy at gmail : @wescpy
<http://twitter.com/wescpy>
Python training & consulting : http://CyberwebConsulting.com
"Core Python" books : http://CorePython.com
Python blog: http://wescpy.blogspot.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] “has a value of True” versus “evaluates true” (was: don't understand iteration)

2014-11-11 Thread Clayton Kirkwood
So, there is a difference between None and False, is that the issue? I don’t 
necessarily see the difference as stated in the subject line. 

A=True

If  A == True

If A

 

Is this the crux of the issue?

 

BTW, the feedback to my submittal suggests that this is a difference with no 
distinction.

 

Clayton

 

From: wesley chun [mailto:wes...@gmail.com] 
Sent: Monday, November 10, 2014 11:35 PM
To: c...@godblessthe.us
Cc: Ben Finney; tutor
Subject: Re: [Tutor] “has a value of True” versus “evaluates true” (was: don't 
understand iteration)

 

good catch, and definitely a distinction beginners should be more cognizant of.

it's also good to recognize that a call to "bool(match)" would render that 
statement correct, as the built-in/factory function will return what an object 
evaluates to (True [re.match object] or/vs.False [None]).

 

On Mon, Nov 10, 2014 at 5:31 PM, Clayton Kirkwood  wrote:

I reported it. I feel all grown up now. Kind of like one of the boys(girls...)

Clayton:<)



>-Original Message-
>From: Tutor [mailto:tutor-bounces+crk <mailto:tutor-bounces%2Bcrk> 
>=godblessthe...@python.org] On
>Behalf Of Ben Finney
>Sent: Monday, November 10, 2014 3:24 PM
>To: tutor@python.org
>Subject: [Tutor] “has a value of True” versus “evaluates true” (was:
>don't understand iteration)
>
>"Clayton Kirkwood"  writes:
>
>> Also of confusion, the library reference says:
>>
>> Match objects always have a boolean value of True. Since match() and
>> search() return None when there is no match, you can test whether
>> there was a match with a simple if statement:
>>
>> match = re.search(pattern, string)
>> if match:
>> process(match)
>
>The documentation is incorrect, as you point out: “have a boolean value
>of True” implies that the value is identical to the built-in ‘True’
>constant, which is never the case for these objects.
>
>Instead, the passage above should say “evaluates true in a boolean
>context”.
>
>Would you be so kind as to report a bug to that effect
>http://bugs.python.org/>?
>
>--
> \   “The Vatican is not a state.… a state must have people. There |
>  `\are no Vaticanians.… No-one gets born in the Vatican except by |
>_o__)an unfortunate accident.” —Geoffrey Robertson, 2010-09-18 |
>Ben Finney
>
>___
>Tutor maillist  -  Tutor@python.org
>To unsubscribe or change subscription options:
>https://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor




-- 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A computer never does what you want... only what you tell it."
+wesley chun <http://google.com/+WesleyChun>  : wescpy at gmail : @wescpy 
<http://twitter.com/wescpy> 
Python training & consulting : http://CyberwebConsulting.com
"Core Python" books : http://CorePython.com
Python blog: http://wescpy.blogspot.com

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] “has a value of True” versus “evaluates true” (was: don't understand iteration)

2014-11-12 Thread Steven D'Aprano
On Tue, Nov 11, 2014 at 10:24:00AM +1100, Ben Finney wrote:
> "Clayton Kirkwood"  writes:
> 
> > Also of confusion, the library reference says:
> >
> > Match objects always have a boolean value of True. Since match() and
> > search() return None when there is no match, you can test whether there was
> > a match with a simple if statement:
> >
> > match = re.search(pattern, string)
> > if match:
> > process(match)
> 
> The documentation is incorrect, as you point out: “have a boolean value
> of True” implies that the value is identical to the built-in ‘True’
> constant, which is never the case for these objects.

I disagree with that interpretation. "X has a boolean value of 
True" does not imply that X is necessarily True, but only that bool(X) is 
True. Is the same way we might say:

Lists have a string representation with [ and ] delimiters 
and , item separators

I trust that you wouldn't interprete that as meaning that lists *are* 
strings.

If the documentation said that match objects *are* the boolean value 
True, then you would be correct, but it doesn't. Your interpretation 
confuses "has" for "is".

To put it another way, "X has a boolean value of True" is synonymous 
with any of these alternative ways of saying the same thing:

"X evaluates like True in a boolean context"

"X is truthy"

"X is a truthy value"

"X is a true-like value"

"X is equivalent to the bool True in boolean contexts"

"X has the quality of being interpreted as true in boolean contexts"

"bool(X) returns True"

and many other ways of saying the same thing.



> Instead, the passage above should say “evaluates true in a boolean
> context”.
> 
> Would you be so kind as to report a bug to that effect
> http://bugs.python.org/>?

I shouldn't bother if I were you :-)



-- 
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor