Message194712
| Author |
py.user |
| Recipients |
docs@python, ezio.melotti, py.user, r.david.murray, rhettinger, serhiy.storchaka, terry.reedy |
| Date |
2013年08月09日.01:13:56 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1376010837.17.0.322946398209.issue18301@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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
>>> |
|