[Python-ideas] a sorting protocol dunder method?

Mark Lawrence breamoreboy at gmail.com
Mon Dec 4 13:22:05 EST 2017


On 04/12/17 18:01, brent bejot wrote:
> I'm +1 on this idea for the most part.
> 
> I agree particularly with the idea that it is better OOP for an object 
> to access it's member variables to create the key than an external 
> container to do so.
> 
>  > and then sort like this:
>  > sorted(list_of_attrdicts, key=AttrDict._id_order)
> 

Isn't this exactly what the operator module's itemgetter and attrgetter 
all ready give you?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Python-ideas mailing list