Message400502
Yeah, you got the gist of what I meant, though, I guess that was a confusing example since there are apparently protocols for Iterable. But not for many of the other collection ABCs such as Sequence, e.g., the following doesn't work:
from typing import Sequence, Protocol
class SequenceWithMethod(Sequence, Protocol):
def method(self) -> None: pass
In which case, anything that implements `method`, `__getitem__`, `__len__`, `__contains__`, `__iter__`, `__reversed__`, `index`, and `count` would be considered a subtype of `SequenceWithMethod` |
|
Date |
User |
Action |
Args |
2021-08-28 20:35:26 | anuppari | set | recipients:
+ anuppari, gvanrossum, JelleZijlstra, kj |
2021-08-28 20:35:26 | anuppari | set | messageid: <1630182926.64.0.275200307151.issue45024@roundup.psfhosted.org> |
2021-08-28 20:35:26 | anuppari | link | issue45024 messages |
2021-08-28 20:35:26 | anuppari | create | |
|