Argument against iterable ints...
Just van Rossum
just at xs4all.nl
Sun Apr 7 01:28:01 EST 2002
[Magnus Lie Hetland]
> Just a situation that cropped up recently: While writing a little
> generator for flattening nested iterables, I used
>
> try: iter(foo)
> except: return foo
> else:
> ....
>
> (of course I could have used a for loop directly in the try clause --
> that doesn't change anything.)
>
> If integers became iterable, this sort of code would suddenly become
> infinitely recursive. Given the propensity for using exceptions in
> this manner rather than type checking in Python, this seems like a
> weighty argument to me...
No matter how I dislike iterable ints, this argument stinks, as the
situation you describe already exists with strings: each element of a
string is itself a string and...
Just
More information about the Python-list
mailing list