__peter__ at web.de
Wed Oct 4 12:24:48 CEST 2006
> Am Wed, 04 Oct 2006 12:03:41 +0200 schrieb Fredrik Lundh:
>> really? iter("SomeString") works just fine for me.
> But then why doesn't dir('SomeString') show an __iter__ method? Seems to
> be implmented differently than with e.g. lists?
The older pre-__iter__() iteration style relying on __getitem__() still
>>> class A:
... def __getitem__(self, index):
... return [3,2,1][index]
>>> for item in A():
... print item
> Know why?
No idea. Perhaps nobody cared?
More information about the Python-list