Fixed length lists from .split()?

Bob Greschke bob at passcal.nmt.edu
Thu Feb 1 14:40:04 EST 2007


This idiom is what I ended up using (a lot it turns out!):

Parts = Line.split(";")
Parts += (x-len(Parts))*[""]

where x knows how long the line should be.  If the line already has 
more parts than x (i.e. [""] gets multiplied by a negative number) 
nothing seems to happen which is just fine in this program's case.

Bob




More information about the Python-list mailing list