[Python-ideas] zip_strict() or similar in itertools ?
Wolfgang Maier
wolfgang.maier at biologie.uni-freiburg.de
Thu Apr 4 14:04:42 CEST 2013
Alfredo Solano MartÃnez <asolano at ...> writes:
>
> Hi,
>
> Have you tried using a marker as fill value and then look for it to
> raise the exception? The membership operator is quite decent, IIRC.
>
> Alfredo
>
Sure, that would be the alternative, but it's not a very general solution
since you would have to figure out a fill marker that can never be part of
the specific iterable. What's worse is that you're retrieving several
elements per iteration, and those different elements may have different
properties requiring different markers. For example, in a file every first
line might be an arbitrary string, every second a number, every third could
optionally be blank, and so on. So I guess, catching the problem early and
raising an error right then, is a simpler and clearer solution.
Wolfgang
More information about the Python-ideas
mailing list