Re: Packing a list of lists with struct.pack()

2006-04-27 Thread Panos Laganakos
Unfortunately I'm familiar with the generator concept, I'll look into it though, 'cause it saved me at least once already :) Thanks mate. -- http://mail.python.org/mailman/listinfo/python-list

Re: Packing a list of lists with struct.pack()

2006-04-27 Thread Fredrik Lundh
Panos Laganakos wrote: > What I don't understand is what are you doing with *(...), this is > supposed to pack its contents as a list? the *arg form treats each value in the arg sequence as a separate argument. for example, arg = 1, 2, 3 function(*arg) is the same thing as function

Re: Packing a list of lists with struct.pack()

2006-04-26 Thread Panos Laganakos
Fredrik, thanks alot. Your preposition worked like a charm, plus I got to learn how to reverse an inner for loop using list comprehensions :) What I don't understand is what are you doing with *(...), this is supposed to pack its contents as a list? -- http://mail.python.org/mailman/listinfo/py

Re: Packing a list of lists with struct.pack()

2006-04-24 Thread Fredrik Lundh
Panos Laganakos wrote: > I have a list that includes lists of integers, in the form of: > li = [[0, 1, 2], [3, 4, 5], ...] > What can I do to get li as a single list of integers? > > I tried list comprehension in the form of: > [([j for j in i]) for i in li] > > But that doesn't seem to work, any

Re: Packing a list of lists with struct.pack()

2006-04-24 Thread Panos Laganakos
Just came up with this: litemp = [] [litemp.extend(i) for i in li] Seems to give me a list with all the inner elements of li, not sure if struct.pack will accept it now, but I'll give it a try. -- http://mail.python.org/mailman/listinfo/python-list

Packing a list of lists with struct.pack()

2006-04-24 Thread Panos Laganakos
Hello, I have a list that includes lists of integers, in the form of: li = [[0, 1, 2], [3, 4, 5], ...] packed = struct.pack(str(len(li)*3)+'i', li) The frmt part is right, as I'm multiplying by 3, 'cause each inner list has 3 elements. What can I do to get li as a single list of integers? I tr