Question on sort() key function

Paul Rubin http
Tue Jan 22 03:50:04 EST 2008


Robert Latest <boblatest at yahoo.com> writes:
> flist.sort(key=File.mod_date.toordinal)
> 
> However, Python says:
> AttributeError: class File has no attribute 'mod_date'

The attribute is on instances of File, not on the class itself.  See
if this works:

   flist.sort(key=lambda f: f.mod_date.toordinal)



More information about the Python-list mailing list