reduce to be removed?

Dustan DustanGroups at gmail.com
Sun Nov 12 02:42:32 CET 2006


Fredrik Lundh wrote:
> Dustan wrote:
>
> >>  > Because I'm embedding this expression in a list comprehension
> >>
> >> because?
>  >
> > Because I thought I would be able to get an answer without revealing
> > the exact details of what I am doing.
>
> alright, let's try again: why do you need a self-contained reduce
> replacement that can be embedded inside a list comprehension ?
>
> </F>


>>> foo =\
[[[1,2,3],[4,5,6],[7,8,9]],
 [[3,2,1],[6,5,4],[9,8,7]]]

Here, foo appears to be a 3-dimensional list - except it's supposed to
be 2-dimensional. The inner-list-of-lists is a result of how I'm
producing the data, and now I want to do a mass-concatenation (or
extending) of the inner-list-of-lists, and come up with this result:

>>> foo == [[1,2,3,4,5,6,7,8,9],[3,2,1,6,5,4,9,8,7]]
True

What's the best way to accomplish this?

It's not quite this simple, but let's just see what you can come up
with the information at hand, and I'll see if I can adapt it to my
needs.




More information about the Python-list mailing list