Bug? If not, how to work around it?

Gonçalo Rodrigues op73418 at mail.telepac.pt
Wed Aug 6 21:40:25 CEST 2003


Hi,

Consider the following class:

>>> class Test(object):
... 	def __init__(self, obj):
... 		self.__obj = obj
... 	def __getattr__(self, name):
... 		return getattr(self.__obj, name)
... 	

Now:

>>> a = Test([])
>>> a.__iter__
<method-wrapper object at 0x0112CF30>
>>> iter(a)
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
TypeError: iteration over non-sequence
>>> 

Is this a bug? If not, how to code Test such that iter sees the
__iter__ of the underlying object?

With my best regards,
G. Rodrigues

P.S: Tested with the latest 2.3 on win2k.




More information about the Python-list mailing list