Ian Kelly <[email protected]> writes:
> T = TypeVar('T')
> def adder(a: T, b: T) -> T: ...
> I'm not thrilled about having to actually declare T in this sort of
> situation, but I don't have a better proposal.
Oh man, that's ugly. Maybe a decorator would be a bit less awful:
@-typevar T
def adder(a: T, b: T) -> T: ...
I'm using @- for a hypothetical decorator that receives the AST for the
stuff on the rest of the line, instead of being evaluated as a function.
The above looks sort of like C++, which would say
template <typename T>
T addr (T a, T b) { ... }
--
https://mail.python.org/mailman/listinfo/python-list