[issue23153] Clarify Boolean Clause Results

2015-01-03 Thread R. David Murray
R. David Murray added the comment: I mistyped 'josh' as 'joel', sorry. Ethan covers it pretty well, but I'll add a few things. Boolean operators are indeed not always used in a boolean context. There is a long tradition in Python of using them to return values via the short-circuit

[issue23153] Clarify Boolean Clause Results

2015-01-03 Thread John Potelle
John Potelle added the comment: I'm learning Python and informing you this is confusing - and you close the ticket without hearing any response to your questions? Re: Josh 1. To show how to return a Boolean result from a Boolean clause. If there's a better way, I'm all for it. 2. Most is a

[issue23153] Clarify Boolean Clause Results

2015-01-03 Thread R. David Murray
R. David Murray added the comment: Indeed, the short circuit and value return behavior is described in that section just before the example. I agree with Joel. This is a tutorial, and part of the zen of Python is that all expressions have a boolean value. There are very few places in python

[issue23153] Clarify Boolean Clause Results

2015-01-03 Thread Ethan Furman
Ethan Furman added the comment: Apologies, my wording was poor -- the last item evaluated is the one returned, but all items may not be evaluated. As soon as the answer is known Python stops evaluating any remaining items. So in the example: -- string1, string2, string3 = '', 'Trondheim',

[issue23153] Clarify Boolean Clause Results

2015-01-03 Thread John Potelle
John Potelle added the comment: Thank you for your reasoned responses. I'm beginning to see just how much Python is its own animal. This and/or thing has history; I get it. Links back to the reference documentation is a good idea. -- ___ Python

[issue23153] Clarify Boolean Clause Results

2015-01-02 Thread Ethan Furman
Ethan Furman added the comment: `or` does not return the last item evaluated -- it returns the first truthy item, or, if no truthy items, the last false item: -- 0 or {} {} -- 0 or 1 or {} 1 -- nosy: +ethan.furman ___ Python tracker

[issue23153] Clarify Boolean Clause Results

2015-01-02 Thread Josh Rosenberg
Josh Rosenberg added the comment: A few questions/comments: 1. How would the reference clarify matters? 2. Most languages is perhaps overstating the matter. Lower level languages and strictly typed languages tend to return a boolean value, but many high level scripting languages (among them

[issue23153] Clarify Boolean Clause Results

2015-01-02 Thread John Potelle
New submission from John Potelle: From v3.4 Tutorial section 5.7 It is possible to assign the result of a comparison or other Boolean expression to a variable. For example, string1, string2, string3 = '', 'Trondheim', 'Hammer Dance' string1 or string2 or string3 'Trondheim' bool(string1 or