Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-10 Thread Stefan Arentz
[EMAIL PROTECTED] (Alex Martelli) writes: Stefan Arentz [EMAIL PROTECTED] wrote: Miki [EMAIL PROTECTED] writes: steps.sort(key = lambda s: s.time) This is why attrgetter in the operator module was invented. from operator import attrgetter ...

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-09 Thread Miki
steps.sort(key = lambda s: s.time) This is why attrgetter in the operator module was invented. from operator import attrgetter ... steps.sort(key=attrgettr(time)) HTH, -- Miki [EMAIL PROTECTED] http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-09 Thread Stefan Arentz
Miki [EMAIL PROTECTED] writes: steps.sort(key = lambda s: s.time) This is why attrgetter in the operator module was invented. from operator import attrgetter ... steps.sort(key=attrgettr(time)) Personally I prefer the anonymous function over attrgettr :) S. --

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-09 Thread Alex Martelli
Stefan Arentz [EMAIL PROTECTED] wrote: Miki [EMAIL PROTECTED] writes: steps.sort(key = lambda s: s.time) This is why attrgetter in the operator module was invented. from operator import attrgetter ... steps.sort(key=attrgettr(time)) Personally I prefer the anonymous function

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-07 Thread Marc 'BlackJack' Rintsch
On Fri, 07 Sep 2007 06:57:35 -0700, cjt22 wrote: I have a step class and store in a list step instances A step instance contains variables: name, startTime etc and startTime is stored as a string %H:%M:%S What I would like to do is to be able to sort this list of objects based on the

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-07 Thread Stefan Arentz
[EMAIL PROTECTED] writes: Hi there I am fairly new to Python and have not really used regular expressions before (I think this might be needed for my query) and wondered if you could help I have a step class and store in a list step instances A step instance contains variables: name,

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-07 Thread Tim Golden
[EMAIL PROTECTED] wrote: Hi there I am fairly new to Python and have not really used regular expressions before (I think this might be needed for my query) and wondered if you could help I have a step class and store in a list step instances A step instance contains variables: name,

Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-07 Thread cjt22
Hi there I am fairly new to Python and have not really used regular expressions before (I think this might be needed for my query) and wondered if you could help I have a step class and store in a list step instances A step instance contains variables: name, startTime etc and startTime is stored