473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

FW: FW: Python help group

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:sw*******@gmail.com]
Sent: Tuesday, March 22, 2005 1:25 PM
To: Leeds, Mark
Cc: py*********@python.org
Subject: Re: FW: Python help group

On Tue, 22 Mar 2005 13:15:15 -0500, Leeds, Mark wrote:
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.


class Student: ... 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.

--
Swaroop C H
Blog: http://www.swaroopch.info
Book: http://www.byteofpython.info
Jul 18 '05 #1
0 1197

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Josiah Carlson | last post by:
QOTW: "Python, the language that wraps tightly around a problem and swallows it whole." -- Raymond Hettinger Because it is so important, this link is re-posted for the future (originally...
0
by: Josiah Carlson | last post by:
QOTW: "XML with elementtree is what makes me never have think about XML again." -- Istvan Albert "'Plays well with others' was a strong motivator for Python's design, and that often means...
0
by: Simon Brunning | last post by:
QOTW: "Python is more concerned with making it easy to write good programs than difficult to write bad ones." - Steve Holden "Scientists build so that they can learn. Programmers and engineers...
0
by: Diez B. Roggisch | last post by:
QOTW: "If I wanted to write five lines instead of one everywhere in a Python program, I'd use Java." -- Paul Rubin http://groups.google.com/group/comp.lang.python/msg/6fac4f3022acd1fa?hl=de& "i...
1
by: Jack Diederich | last post by:
QOTW: "Regexps are a brittle tool, best tolerated in small doses." - Tim Peters "Simplicity is prerequisite for reliability" - Edsger W. Dijkstra eval(repr(var)) sometimes works for...
0
by: Paul Boddie | last post by:
QOTW: "I think you've got the wrong intuition about the balance between the amount of bandwidth and the amount of computation a given numer of dollars would buy. You've hundreds of CPU cycles...
1
by: Gabriel Genelli | last post by:
QOTW: "A java class full of static methods translates to a python module populated with functions in general." - Arnaud Delobelle "Neurons are far more valuable than disk space, screen lines, or...
0
by: Gabriel Genellina | last post by:
QOTW: "However, inspection of a vast corpus of code might lead one to believe that any commenting capability was completely unnecessary." - Jim B. Wilson "The Python people also piped to say...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.