Python Sanity Proposal: Type Hinting Solution

Paul Rubin no.email at nospam.invalid
Sat Jan 24 18:37:36 CET 2015


Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:
> versus any other decorator, but the STRING:
> "@typehint(...)"
> being used where a decorator would normally be expected.

I didn't catch that either.  I think if hints are to go in decorators,
then it's best to extend the decorator mechanism to allow arbitrary
syntax, e.g.

@-typehint (str, int) -> bool

The @- would signify that the typehint function is to receive an AST as
its argument, rather than its callable.  The AST would be the parse tree
for the rest of the line.  Alternatively, it could get the line as a
string and parse it with appropriate functions from the ast module.



More information about the Python-list mailing list