Operator Precedence/Boolean Logic

Chris Angelico rosuav at gmail.com
Sun Jul 17 03:33:02 EDT 2016


On Sun, Jul 17, 2016 at 4:44 PM, Rustom Mody <rustompmody at gmail.com> wrote:
> I am sure Chris you can distinguish between:
>
> - Python’s (bool) model is bizarre
> - The model “Everything has auto-bool-nature” is bizarre
> - The notion « “Everything has auto-bool-nature” is straightforward » is bizarre
>
>
> My earlier statement (with emphasis in original):
>> You also have a bizarre notion that python's property: “Everything has
>> auto-bool-nature” IS STRAIGHTFORWARD.

I can distinguish them, yes. But Python's boolification model is
fundamentally the same as the model "Everything has auto-bool-nature".
So those two aren't really all that different, save that one of them
is language-agnostic.

I understand your third statement, but I posit that these last points
have proven it false. There are clearly a number of viable semantic
systems:

1) REXX and, I think, Pascal: there are two specific values that may
be used in conditionals, and anything else is an error
2) Everything is legal in a conditional, and has a truth value
2a) Pike: 0 is false, every other object is true, unless it defines a
magic method
2b) Python: Empty values and collections are false, everything else is
true, unless it defines a magic method
2c) JavaScript: 0, null, undefined, nan, "", false are false,
everything else is true, including all objects (no magic method
option)
3) Machine code: There are no conditionals - just CPU flags that you
can jump or not jump on.

All of them work. So you could *disagree* with the statement that
Python's model is straight-forward, but you cannot say that this
statement is *bizarre*.

ChrisA



More information about the Python-list mailing list