Need a strange sort method...
Neil Cerutti
horpner at yahoo.com
Mon Oct 16 15:20:44 EDT 2006
On 2006-10-16, Tim Chase <python.list at tim.thechases.com> wrote:
> If you need it in a flat list, rather than as a list of
> chunk_size lists (which are handy for iterating over in many
> cases), there are ways of obtaining it, such as the hackish
>
> >>> sum([a[i::chunk_size] for i in range(chunk_size)], [])
> [1, 4, 7, 10, 2, 5, 8, 3, 6, 9]
>
> There are likely good recipes for flattening a list. I just
> happen not to have any at my fingertips.
Actually, there isn't a good recipe in Python for flattening a
list. They all come out tasting like Circus Peanuts (Turkish
Delight for you non-Yanks).
--
Neil Cerutti
More information about the Python-list
mailing list