something for itertools

Tim Williams tim at tdw.net
Fri Sep 15 19:49:49 EDT 2006


On 15/09/06, Daniel Nogradi <nogradi at gmail.com> wrote:

> > or maybe a one liner  :)
> >
> > >>> (a + 5*(None,))[:5]
> > (1, 2, 3, None, None)
> >
>
> Well, something like this is what I actually do. But for this first I
> have to loop over all tuples and pick out the maximal length, so over
> all it won't be a one liner but two loops.

I meant it as a one line answer to your padding query,  you would
still need to iterate over you collection of tuples as it only acts on
1 tuple at a time.

That said, its not too difficult to get the whole process, including
finding the maximal length to a 2 liner once you have collected your
tuples :)



More information about the Python-list mailing list