
Jan. 22, 2009
7:25 p.m.
On Wed, 21 Jan 2009 14:55:08 +0100, Mathias Panzenböck wrote:
Arnaud Delobelle schrieb:
How about this?
from itertools import * def fixlen(iterable, len, item=None): ... return islice(chain(iterable, repeat(item)), len) ... list(fixlen([1, 2, 3], 5)) [1, 2, 3, None, None]
I like this. Maybe an addition to itertools?
+1
I opened an issue_ at the Python bug tracker. .. _issue: http://bugs.python.org/issue5034 -- Robert "Stargaming" Lehmann