
list(fixlen([1, 2, 3], 5))=0A> > [1, 2, 3, None, None]=0A> >=0A> =0A> I=
MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable ----- Mensaje original ----=0A> De: Mathias Panzenb=F6ck <grosser.meister.m= orti@gmx.net>=0A> Para: Arnaud Delobelle <arnodel@googlemail.com>=0A> CC: p= ython-ideas@python.org=0A> Enviado: mi=E9rcoles, 21 de enero, 2009 10:55:08= =0A> Asunto: Re: [Python-ideas] min_fields argument to str.split()=0A> =0A>= Arnaud Delobelle schrieb:=0A> >=0A> > How about this?=0A> >=0A> >>>> from = itertools import *=0A> >>>> def fixlen(iterable, len, item=3DNone):=0A> > .= ..=A0 =A0 return islice(chain(iterable, repeat(item)), len)=0A> > ...=0A> >= like this. Maybe an addition to itertools?=0A> =0A> +1=0A=0A+1 from me too= .=A0Way better than the generator I proposed. Having this as a function als= o makes it=A0applicable to much more than just one use case.=0A=0AIf you se= e the following code:=0A=0Aa,b,c,d =3D fixlen(str.split(),4)=0A=0Ayou immed= iately know it's not a regular unpacking operation; it will be the first pl= ace you look if something goes wrong.=0A=0A=0AVitor=0A=0A=0A =A1Todo s= obre la Liga Mexicana de f=FAtbol! Estadisticas, resultados, calendario, fo= tos y m=E1s:<=0Ahttp://espanol.sports.yahoo.com/