[Tutor] calculating a sort key and operator.attrgetter()
vincent at vincentdavis.net
Wed Jul 1 05:39:35 CEST 2009
I have a class with an attribute which is a list "rank_list" this is a list
of instances f another class that has attributes "quality, is_observed"
if I want to sort the list by the attribute "quality" I can just use,
But I want to sort like this.
operator.attrgetter('is_observed') * self.does_observe))
Will this work or is there a better way?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor