Steven D'Aprano wrote:
> On Tue, 10 Jul 2007 13:13:38 -0600, Steven Bethard wrote:
> 
>> It's much easier to explain to newcomers that *, + and - work on True 
>> and False as if they were 1 and 0 than it is to introduce them to a two 
>> element boolean algebra. So making this kind of change needs a pretty 
>> strong motivation from real-world code.
> 
> Pretending that False and True are just "magic names" for 0 and 1 might be
> "easier" than real boolean algebra, but that puts the cart before the
> horse. Functionality comes first: Python has lists and dicts and sets
> despite them not being ints, and somehow newcomers cope. I'm sure they
> will cope with False and True not being integers either.
> 
> I mean, really, does anyone *expect* True+True to give 2, or that 2**True
> even works, without having learnt that Python bools are ints? I doubt it.
> 
> And the old Python idiom for an if...then...else expression:
> 
> ["something", "or other"][True]
> 
> tends to come as a great surprise to most newbies. So I would argue that
> bools being ints is more surprising than the opposite would be.

I disagree. I think you'd get just as many odd stares if:

     True + True == True

But I think all you're really saying is that newbies don't expect things 
like +, -, *, etc. to work with bools at all. Which I agree is probably 
true.

So it seems like you're really arguing for raising exceptions in all 
these situations. That would actually be fine with me since I never use 
bools as ints, but I suspect getting it past python-dev will be an 
uphill battle since it will break large chunks of code.

STeVe
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to