Sorting out sort
Mel Wilson
mwilson at the-wire.com
Mon Jan 6 16:43:57 EST 2003
In article <mailman.1041873216.4151.python-list at python.org>,
com-nospam at ccraig.org (Christopher A. Craig) wrote:
>mwilson at the-wire.com (Mel Wilson) writes:
>
>> But I'm not personally comfortable with hiding that big
>> side effect inside an innocent-looking expression, even if
>> cognoscenti have learned to raise a red flag anytime they see
>> '.sort('. There's already enough entry-level confusion with
>
>I'm rather suprised you're willing to hide the time loss in such an
>innocent looking expression. If I have something that could take
>several seconds to run, I'd really rather see it have its own line.
That was the big side effect I referred to. I'm not
necessarily in love with putting expensive operations on
their own lines, but it's a shame go to all the trouble of
sorting a list and then throwing the result away, perhaps to
sort it all over again later. Better to bind it with a name
and re-use it.. which in Python, as you say, takes a
separate line of code. Of course, like others, if I needed
a sorted copy my first thought would be to write a function
(perhaps called sorted_copy) that built me one.
Regards. Mel.
More information about the Python-list
mailing list