permuting letters and fairy tales

Kent Johnson kent3737 at
Sat Nov 13 14:40:24 CET 2004

Bengt Richter wrote:
> But it does bring up a general problem of final logic in an iter loop. ISTM it could
> be useful to have an option not to raise StopIteration, but instead keep returning
> a specified sentinel at the end, something like returns '' repeatedly at EOF.

 From the itertools examples:
 >>> def padnone(seq):
...     "Returns the sequence elements and then returns None indefinitely"
...     return chain(seq, repeat(None))


More information about the Python-list mailing list