[Tutor] Re: Re: list method sort()
sigurd at 12move.de
Fri Apr 2 16:22:20 EST 2004
On 2 Apr 2004, Tim Peters <- tim.one at comcast.net wrote:
>> Well, yes, you can argue that *all* operations which modify in-place
>> should return the modified object as well - I don't know if this
>> would be better or not: ...
> Life would be hell in interactive Python shells if these things *didn't*
> return None:
> Oops! Nobody wants to sit and wait for an arbitrary amount of output then.
Regarding an interactive session I agree with you.
> Against my better judgment, Python 2.4 is adding a sorted() function to the
> builtins, to stop people whining about this particular case. That's against
> my wishes because bloating the builtins with functions that are trivially
> written in one or two lines bloats the builtins with functions that are
> trivially written in one or two lines <wink>.
Here I also agree with you (the sort example can be written in three
lines (and the penalty in performance should be negligible). But we
also got sum, min and max. All three can simply (and clearly) be
written with reduce.
sort() gets new keywords IIRC; wouldn't it have be an option to simply
add another keyword -- `return_value' -- which defaults to False?
Please do *not* send copies of replies to me.
I read the list
More information about the Tutor