FW: FW: Python help group

L

Leeds, Mark

This is a follow up question
To the previous question
About sorting that
I sent for my friend.





-----Original Message-----
From: Tan, Heap Ho
Sent: Tuesday, March 22, 2005 2:06 PM
To: Leeds, Mark
Subject: RE: FW: Python help group

How can you speed it? Does anyone know if pytable can take
non-homogeneous objects type?


-----Original Message-----
From: Leeds, Mark
Sent: Tuesday, March 22, 2005 1:39 PM
To: Tan, Heap Ho
Subject: FW: FW: Python help group



-----Original Message-----
From: Swaroop C H [mailto:[email protected]]
Sent: Tuesday, March 22, 2005 1:25 PM
To: Leeds, Mark
Cc: (e-mail address removed)
Subject: Re: FW: Python help group

I want to do a sort on a list of objects based on a similar attributes in
each object for example time of creation of this object.
... def __init__(self, name, age):
... self.name = name
... self.age = age
...
>>>
>>> students = [Student('John', 18), Student('Jill', 17)]
>>> students.sort(lambda x,y: cmp(x.age, y.age))
>>> [student.name for student in students] ['Jill', 'John']
>>>

See `help(list.sort)` for details.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top