PEP 308: ternary operator

Terry Hancock hancock at anansispaceworks.com
Sat Feb 22 01:30:21 EST 2003


Erik Max Francis wrote:
> phil hunt wrote:
>> No, it suggests that we should we should make things easy for the
>> majority of python programmers who also use other languages. Python
>> will never become C or Perl, it will always be Python. However,
>> Python shares lots of features with these langauges (and other
>> langs) already, for example: use of "if" keyword to denote
>> conditionals, use of symbols "0123456789" to denote numbers, use of
>> "+" to denote addition, use of "=" to denote assignment, etc, etc.

Everything you've mentioned so far is also true of Western mathematics in 
general, not just C.  As such they are exceedingly trivial and irrelevant 
to the discussion of something as arcane and arbitrary as "c?a:b".

> And more than that, Python really takes a lot of cues from the C family
> of languages (as do many modern high-level languages).  Take == vs. =,
> or a 0x prefix for hexadecimal literal and a 0 prefix for an octal
> literal, etc.

Sure.  Because those happened to be pretty good ideas, and not particularly 
hard to remember.

But what about:

a = 6.7
b = 2.3
c = a**b

Try that in C.

Works in Fortran, of course.  Not in Basic.  And why should we care?

Of course they all support exponentiation in some way, but that's not the 
point.  I happen to think this is a pretty easy to remember choice.

Also, these are all used *much* more often, so clarity matters less.  You 
need to be clearest with things that are used less often, because those are 
the ones you're most likely to forget (or not have learned yet).

Cheers,
Terry

-- 
Anansi Spaceworks
http://www.anansispaceworks.com




More information about the Python-list mailing list