PEP 308: ternary operator

sismex01 at hebmex.com sismex01 at hebmex.com
Fri Feb 21 11:04:33 EST 2003


> From: philh at cabalamat.uklinux.net [mailto:philh at cabalamat.uklinux.net]
> Sent: Friday, February 21, 2003 7:51 AM
> 
> On Thu, 20 Feb 2003 22:02:51 GMT, Raymond Hettinger 
> >Also, the use of c?a:b in other languages is an important
> >consideration so that skills are transferrable both to and
> >from Python.   That syntax is used in enough other places
> >to make it a valuable thing to know.
> 
> Does anyone have an estimate of the proportion of Python programmers
> who know at least one C-syntax language? My guess is that at least
> 66% of us do.

And that proves.... what?  That it's justifiable to turn Python
into a pseudo-C, pseudo-Perl kind of language just because at
least 66% of us know them?

Python has a beautiful syntax, utterly wonderful to read in
that it's just like skimming pseudo-code; I believe it would
be terrible to lose that, just because it's easier to type

     x = condition ? value : else_value

instead of stopping what you're doing and thinking long and
hard on what kind of syntax to use for __THIS__ particular
language, a new construct which won't contaminate the
current syntax with imported idioms that aren't truly part
of the Python we know.  It should be an extension of Python,
not an import from C/Perl/Java.

Sometimes we gotta stop what we're doing and think long and
hard on a problem, in order to find the best solution.  I think
that finding the correct syntax for Python's ternary operator
is one of those problems, because it's use is going to spread
veru fast, so there's no taking it back nor changing it to
something else later.

I don't envy Guido one bit, he's got his work cut out for him.
So maybe he should sit on what's come out of this little
experiment, and think for a while; the best implementation
is gonna come to him.

In the end, I hope it's some "wordy" scheme, and not one based
on line-noise, like C's.  Why? Because Python *is* a wordy
language, and the ternary operator is more like a compact
if-then-else, than a + or -, so (IMO) it should follow that
form.

Salutations :-)

-gustavo





More information about the Python-list mailing list