reduce to be removed?

Dustan DustanGroups at gmail.com
Sat Nov 11 19:15:26 EST 2006


Fredrik Lundh wrote:
> Dustan wrote:
>
>  > Because I'm embedding this expression in a list comprehension
>
> because?
>
> </F>

Because I thought I would be able to get an answer without revealing
the exact details of what I am doing. I didn't realize that wasn't an
option. I'll try once more to give you an idea of what I'm trying to
accomplish without letting on the details.

>>> 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:

>>> 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