Comparison function as class method: how?
Jeff Stewart
object01 at hotmail.com
Thu May 8 11:30:34 EDT 2003
I was writing a small class yesterday that maintains a list of file
statistics. I want this class to have a sortByModTime() method, but I
couldn't get Python to accept a sort()-compatible comparison function as a
class method. It kept telling me that the function expected 'self' as the
first argument. I understand that all class methods have this requirement,
but surely there's a way to encapsulate a comparison function in the class
containing the data it sorts!
Is there a way to pull this off?
--
Jeff S.
More information about the Python-list
mailing list