[docs] [issue18301] In itertools.chain.from_iterable() there is no cls argument

py.user report at bugs.python.org
Fri Aug 9 03:13:57 CEST 2013


py.user added the comment:

changed iter(arg) to *arg


>>> import itertools
>>> 
>>> class A(itertools.chain):
...     @classmethod
...     def from_iter(cls, arg):
...         return cls(*arg)
... 
>>> class B(A):
...     pass
... 
>>> B('ab', 'cd')
<__main__.B object at 0x7fc280e93cd0>
>>> b = B.from_iter(['ab', 'cd'])
>>> b
<__main__.B object at 0x7fc280e93d20>
>>> next(b)
'a'
>>> next(b)
'b'
>>> next(b)
'c'
>>> next(b)
'd'
>>> next(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
StopIteration
>>>

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18301>
_______________________________________


More information about the docs mailing list