Argument against iterable ints...

Magnus Lie Hetland mlh at vier.idi.ntnu.no
Fri Apr 5 21:36:36 EST 2002


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...

--
Magnus Lie Hetland                                  The Anygui Project
http://hetland.org                                  http://anygui.org



More information about the Python-list mailing list