[Python-ideas] [Wild Idea] Static Ducks

Dj Gilcrease digitalxero at gmail.com
Tue Sep 22 13:18:28 CEST 2009


On Mon, Sep 21, 2009 at 6:19 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> It sounds like what you want is a framework for hiding the complexity of
> runtime type checkers from the developer. I don't think there's any
> need for new syntax beyond decorators and the type annotations added to
> Python 3. Type annotations give you a way of declaring types of
> arguments and return results. Although such declarations are currently
> ignored by Python, you can write code to enforce them, and decorators
> give you a neat syntax for applying that code to your functions without
> having to explicitly include the type checks inside the function body.
> You can also do the same with metaclasses.

Ya but decorators, metaclasses and annotations dont address class
attributes, or module level variables, which you should be able to
type check on assignment, but you need to do it on use.



More information about the Python-ideas mailing list