Operator Precedence/Boolean Logic
Grant Edwards
grant.b.edwards at gmail.com
Wed Jun 29 11:00:30 EDT 2016
On 2016-06-29, Steven D'Aprano <steve at pearwood.info> wrote:
> To Nick, having 1+True return 2 is an accident of implementation,
My recollection is that it was not an accident of impliementation. It
was an intentional descision to provide compatibility with many years
worth of programs that were written before there was either a boolean
type or built-in True/False integer values.
Those programs often did this at the top:
True = 1
False = 0
Having True and False evaluate as 1 and 0 in an integer expression
context guaranteed that those programs would to continue to work with
minimal changes.
--
Grant Edwards grant.b.edwards Yow! Life is a POPULARITY
at CONTEST! I'm REFRESHINGLY
gmail.com CANDID!!
More information about the Python-list
mailing list