dictionary issue (and maybe PEP ... depending on the answer)
dsavitsk
dsavitsk at ecpsoftware.com
Mon Jun 2 13:54:07 EDT 2003
andrew cooke wrote:
> dsavitsk <dsavitsk at ecpsoftware.com> writes:
> [...]
>
> you want a non-destructive sort. i want a non-destructive sort. last
> week someone was wanting to add a non-destructive sort with mapping.
> every new user screws up assuming that [].sort is non-destructive.
> even norvig lists it as the big ugly wart in python (well, maybe not
> in those words).
>
> you'd think that someone would add non-destructive sort to python,
> wouldn't you?
>
> funny old world, eh?
>
> andrew
>
Indeed. I've been using this language for going on 6 years and I still
screw this up. I was even so assanine as to assume that since, so far
as i can tell, the most useful thing for list comprehensions (or rather,
the thing that would seemingly justify adding them to the language
beyond the coolness factor) seems to be generating a list in place that
can be passed to a function all in one line, that at least tacking a
.sort() on a list comprehension would be a reasonable sort of thing to
expect.
Oh well, I don't want to be one of those c.l.py people who argues
against decided points and makes everyone here hate them. It does seem,
though, that leaving sort() alone and adding .returned_sort() or
whatever would not be so terrible.
-doug
More information about the Python-list
mailing list