[Python-ideas] logics (was:thoughts on generator.throw())
denis.spir at free.fr
Wed Mar 18 19:23:13 CET 2009
Le Wed, 18 Mar 2009 13:10:52 -0400,
Gerald Britton <gerald.britton at gmail.com> s'exprima ainsi:
> *Then* I wondered why "raise" is a keyword and not a
> function. If it were a function you could use it easily in places
> where today you cannot:
> if 'foo' == 'bar' or raise(FooBar): # only proceed if 'foo'
> equals 'bar' otherwise raise FooBar exception
> is invalid syntax because raise is not a function.
I'm very happy this is invalid syntax :-)
I consider this kind of practice conceptual distortion. More precisely: an abuse of both (!) flow control and logical operator semantics. It reminds me of joyful (hum!) times with C routines written by "clever" people.
I would go much farther that python about logical types and operators.
Lazy evaluation is ok, because the alternative is not simpler:
if n != 0 and 1/n > threshold:
But I'm not happy at all with the following:
>>> (3==3) + 1
>>> 1 or True
I think logical operators (and or not) should accept only logical value. And logical values should not operate with numbers.
la vita e estrany
More information about the Python-ideas