Robert Latest <[EMAIL PROTECTED]> writes:
> >flist.sort(key=lambda f: f.mod_date.toordinal)
>
> It doesn't throw an error any more, but neither does it sort the list. This,
> however, works:
Oh, I didn't realize that toordinal was a callable, given your earlier
sample. You want:
flist.s
On Tue, 22 Jan 2008 09:56:55 +, Robert Latest wrote:
> Peter Otten wrote:
>> Robert Latest wrote:
>>
>> This should work then:
>>
>> def date_key(f):
>> return f.mod_date.toordinal()
>> flist.sort(key=date_key)
>>
>> This can also be written as
>>
>> flist.sort(key=lambda f: f.mod_date.too
Peter Otten wrote:
> Robert Latest wrote:
>
>> Paul Rubin wrote:
>>> 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)
>>
>> It doesn't throw an error any more, but neither does it sort the list. This,
Robert Latest wrote:
> Paul Rubin wrote:
>> 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)
>
> It doesn't throw an error any more, but neither does it sort the list. This,
> however, works:
>
> -
Paul Rubin wrote:
> 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)
It doesn't throw an error any more, but neither does it sort the list. This,
however, works:
--
def by_date(f1, f2):
Robert Latest <[EMAIL PROTECTED]> 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.toordi
Hello,
I have this class:
class File:
def __init__(self):
self.name = ''
self.path = ''
self.date = 0
self.mod_date = 0
self.keywords = []
self.url = ''
...and after creating a list of File o