Reinhold Birkenfeld wrote:
Why not put these together and put it in itertools, since the requirement seems to crop up every other week?

 >>> line = "A:B:C".split(":")
 ...
 >>> def ipad(N,iterable, default = None):
 ...     return it.islice(it.chain(iterable, it.repeat(default)), N)
 ...
 >>> a,b,c,d = ipad(4,line)
 >>> a,b,c,d
('A', 'B', 'C', None)


Good idea!

(+1 if this was posted on python-dev!)

Please, please Google the python-dev archives before doing so ;)

Cheers,
Nick.
I seem to recall 'tuple unpacking' as the appropriate phrase. . .

--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
            http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to