tuples, index method, Python's design

Antoon Pardon apardon at forel.vub.ac.be
Tue Apr 10 06:39:00 EDT 2007


On 2007-04-10, Paul Boddie <paul at boddie.org.uk> wrote:

>> Now with implementation and maintaining. If you would start with a class
>> of sequence which classes like tuple and list would inherit from, then
>> there also would be a single function to be implemented and maintained.
>> It would just be usable in more types.
>
> There isn't a "big win" in this case: the intersection of useful
> methods between mutable and immutable sequence types is rather small.
> Nevertheless, providing a slightly deeper abstract class hierarchy
> might be appropriate, and this is being considered for Python 3000.

Well I wasn't trying to show this aspect as a big win. Just illustrating
it doesn't have to be a big cost in this case.

>> The same happened with the ternary operator. Every use case someone
>> could come up with was rejected by rewriting the code without using
>> a ternary operator. AFAICS the only reason the ternary operator
>> finaly got introduced was because a python developer was bitten by an
>> illusive bug, introduced by one of the idioms that was often used as a
>> way to simulate a ternary operator.
>
> The ternary operator, whilst providing new and occasionally useful
> functionality, is rather "badly phrased" in my opinion: when used,
> it's a bit like reading one natural language and suddenly having the
> grammar of another in use for the rest of the sentence.

I agree. The structure of the if-expression doesn't resemble the
structure of the if-statement. I think it was a bad choice to
have the two so dissimilar.

-- 
Antoon Pardon



More information about the Python-list mailing list