|
|
|
|
|
by hannibalhorn
2086 days ago
|
|
There is a numbers.Number for that - but yeah, that's another way in which it's just not a good example.. I think typing_extensions.Protocol helps support the general duck typing "any object that has method x", though there are some implementation issues w/ dataclasses and such.. |
|
That won't help if I want to square a matrix, or a polynomial.
> typing_extensions.Protocol helps support the general duck typing "any object that has method x"
Even if there's a `powerable` protocol that could be used to annotate `square` and `cube`, how would you annotate a slightly more complex function like `poly`?