Iteration support for __getitem__ can be thought of as an "obsolete function" that allows for a smoother transition when PEP234 introduces iterability as its primary concept. It applies only to classes without __iter__ , where __getitem__ takes integers 0, 1, and c and raises IndexError after the index gets too high (if ever), usually the "sequence" classes encoded before __iter__ , appeared (although nothing prevents you from coding new classes as well).
Personally, I would prefer not to rely on this in the new code, although it is not outdated and does not go away (works fine in Python 3 as well), so this is just a matter of style and taste ("explicit is better than implicit", so I would prefer explicitly maintain iterability, rather than relying on __getitem__ , supporting it implicitly for me, but not big).
Alex Martelli May 29, '09 at 15:37 2009-05-29 15:37
source share