Sorting distionary by value

phil hunt philh at comuno.freeserve.co.uk
Fri Mar 29 11:45:15 EST 2002


On Thu, 28 Mar 2002 17:55:13 -0800, Jeff Shannon <jeff at ccvcorp.com> wrote:
>
>
>phil hunt wrote:
>
>> On Thu, 28 Mar 2002 12:01:15 -0800, Jeff Shannon <jeff at ccvcorp.com> wrote:
>> >
>> >I disagree.  I'm just as happy that Python doesn't try to guess what would be a
>> >suitable "default" value for non-existent keys.
>>
>> The default value should always be None.
>>
>> None should act like 0 or "" or [] or {} where appropriate, i.e.:
>>
>>    None + 1 --> 1
>>    None + "x" --> "x"
>>    None * 4 --> 0
>>    None + ['x'] --> ['x']
>>    None + {2:3} --> {2:3}
>
>I strongly disagree with that.  Next thing you know, you'll be saying that (3 +
>'one' ) should evaluate to 4. 

Not at all.

Actually, I think catenation and addition should have separate 
operators, so:

   [1,2] & [3,4] --> [1,2,3,4]

   [1,2] + [3,4] --> [4,6]

>> >It seems to me to be entirely
>> >consistent with the philosophy of "explicit is better than implicit".
>>
>> But that isn't the philosophy of any high level langauge. In fact,
>> the more high level any language is, the more implicit things are.
>> And I would argue that's a pretty good definition of what a high
>> level language is.
>
>I disagree with your conception of high level language.  A high level language hides
>unnecessary details, but I don't think that conversion between different data types
>is an unnecessary detail.  

So would you prefer:

   float(2) + 3.14

to:

   2 + 3.14

?


>High level means that a logical step can be done in one
>or two lines of code,

Define "logical step".

> not that it does magic transmutations in the background.

Define "magic transmutations". Y'know, the transmutation between 
Python source and machine code is rather complex *already*.

>There's a large class of cases where the interpreter, in trying to "do the right
>thing", is as likely to guess wrongly as it is to guess right.

This is only true if what the interpreter will do is not cleanly 
defined for the programmer.

>  If you want an
>interpreter that guesses anyhow, use Perl.

Yuck.


-- 
<"><"><"> Philip Hunt <philh at comuno.freeserve.co.uk> <"><"><">
"I would guess that he really believes whatever is politically 
advantageous for him to believe." 
                        -- Alison Brooks, referring to Michael
                              Portillo, on soc.history.what-if



More information about the Python-list mailing list