Argument against iterable ints...
Magnus Lie Hetland
mlh at vier.idi.ntnu.no
Sun Apr 7 14:06:21 EDT 2002
In article <just-D808D9.08280107042002 at news1.xs4all.nl>, Just van Rossum wrote:
>[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...
Yes. And I think that stinks. The fact that we have one such problem
in the language is no reason to add another.
Oh, well.
>Just
--
Magnus Lie Hetland The Anygui Project
http://hetland.org http://anygui.org
More information about the Python-list
mailing list