Hi,
Consider the following class:
[color=blue][color=green][color=darkred]
>>> class Test(object):[/color][/color][/color]
.... def __init__(self, obj):
.... self.__obj = obj
.... def __getattr__(sel f, name):
.... return getattr(self.__ obj, name)
....
Now:
[color=blue][color=green][color=darkred]
>>> a = Test([])
>>> a.__iter__[/color][/color][/color]
<method-wrapper object at 0x0112CF30>[color=blue][color=green][color=darkred]
>>> iter(a)[/color][/color][/color]
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
TypeError: iteration over non-sequence[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
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.
Consider the following class:
[color=blue][color=green][color=darkred]
>>> class Test(object):[/color][/color][/color]
.... def __init__(self, obj):
.... self.__obj = obj
.... def __getattr__(sel f, name):
.... return getattr(self.__ obj, name)
....
Now:
[color=blue][color=green][color=darkred]
>>> a = Test([])
>>> a.__iter__[/color][/color][/color]
<method-wrapper object at 0x0112CF30>[color=blue][color=green][color=darkred]
>>> iter(a)[/color][/color][/color]
Traceback (most recent call last):
File "<interacti ve input>", line 1, in ?
TypeError: iteration over non-sequence[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
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.
Comment