A library approach to the ternary operator

Alex Martelli aleax at aleax.it
Wed Mar 26 07:44:25 EST 2003


Miki Tebeka wrote:

> Hello Alex,
> 
>> > to be worth using.  Having a function name ("select") there gives us
>> > something to attach a nice verbose comment to, while the above, since
>> > it uses only language primitives, remains obscure.
>> 
>> Yes, I concur.  Moreover, this ternary.py can easily be widely
>> spread and popularized, to establish a usage base for 'choose'
>> IF people like the approach (I'm not gonna guess if they will) --
>> this may help make a case for 'choose' as a built-in, later, if
>> and only if people like and use it so much as to warrant that.
> 
> One more argument for macros. If we had macros (which I have no idea
> how to implement in Python) we could have checked things like that
> without touching the core interpreter.

"Il mondo e` bello perche` e` vario" (old Italian proverb: "the
world is beautiful because it is diverse").  To ME, the inevitable
proliferation of mutually incompatible "almost-Python" syntaxes that
macros would likely produce, across applications, packages and
frameworks, given people's differing tastes on such syntax-sugar
subjects as ternary operators, is exactly THE key argument AGAINST
having macros in the language.

Note that the suggestion to which I was positively responding
does NOT require "touching the core interpreter" either...;-)


Alex





More information about the Python-list mailing list