Re: [Tutor] Extending a list within a list comprehension

2006-04-12 Thread Kent Johnson
Victor Bouffier wrote: > On Tue, 2006-04-11 at 22:17 -0400, Kent Johnson wrote: >> Victor Bouffier wrote: >> >>> If the second element in each array passed as x is of variable length >>> (that is, it has a different element count than three, in this case), >>> the program needs to extend the list i

Re: [Tutor] Extending a list within a list comprehension

2006-04-11 Thread Victor Bouffier
On Tue, 2006-04-11 at 22:17 -0400, Kent Johnson wrote: > Victor Bouffier wrote: > > > If the second element in each array passed as x is of variable length > > (that is, it has a different element count than three, in this case), > > the program needs to extend the list instead. Without list > > c

Re: [Tutor] Extending a list within a list comprehension

2006-04-11 Thread Kent Johnson
Victor Bouffier wrote: > If the second element in each array passed as x is of variable length > (that is, it has a different element count than three, in this case), > the program needs to extend the list instead. Without list > comprehensions, and the added capability to utilize and sized list a

Re: [Tutor] Extending a list within a list comprehension

2006-04-11 Thread Victor Bouffier
On Tue, 2006-04-11 at 23:42 +0100, Alan Gauld wrote: > Hi Victor, > > I've gotta say that I much prefer the second version here. > > > temporal = [] > > temporal = [ [x[1][1], (x[0], description[x[0]], > >x[1][0], x[1][1], x[1][2] ) ] for x in elements ] > > temporal.sort() > > temporal.rever

Re: [Tutor] Extending a list within a list comprehension

2006-04-11 Thread Alan Gauld
Hi Victor, I've gotta say that I much prefer the second version here. > temporal = [] > temporal = [ [x[1][1], (x[0], description[x[0]], >x[1][0], x[1][1], x[1][2] ) ] for x in elements ] > temporal.sort() > temporal.reverse() # sort descending > elements = [ x[1] for x in temporal ]

Re: [Tutor] Extending a list within a list comprehension

2006-04-11 Thread John Fouhy
On 12/04/06, Victor Bouffier <[EMAIL PROTECTED]> wrote: > elements = [ > (codigo, [ cant, importe, porc]), > (codigo, [ cant, importe, porc]), > ... > ] > > And I want to sort descending on 'importe', which is x[1][1] for x in > elements. In python 2.4, you could achieve this by saying: elements.