Message241692
For the other ABCs, if you define the required abstract methods, you get working versions of all the mixin methods.
In the case of the Generator ABC, throw() and close() are useless empty stub methods. In the other ABCs, we leave optional methods out entirely. A user should expect that if isinstance(g, Generator) is true that all of the ABC methods will work.
Also, the return StopIteration in throw() doesn't seem correct. Shouldn't it raise the exception that was thrown?
>>> def f():
yield x
>>> g = f()
>>> g.throw(KeyError)
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
g.throw(KeyError)
File "<pyshell#9>", line 1, in f
def f():
KeyError
Ideally, there should be a practical example of where this ABC would be useful with anything other than a real generator. |
|
Date |
User |
Action |
Args |
2015-04-21 02:21:57 | rhettinger | set | recipients:
+ rhettinger, gvanrossum, pitrou, scoder, vstinner, lukasz.langa, martin.panter, yselivanov |
2015-04-21 02:21:57 | rhettinger | set | messageid: <1429582917.72.0.169396481175.issue24018@psf.upfronthosting.co.za> |
2015-04-21 02:21:57 | rhettinger | link | issue24018 messages |
2015-04-21 02:21:56 | rhettinger | create | |
|