[Python-ideas] Improving the expressivity of function annotations

Carl M. Johnson cmjohnson.mailinglist at gmail.com
Mon Apr 4 11:17:46 CEST 2011


On Sun, Apr 3, 2011 at 11:09 PM, Carl M. Johnson <
cmjohnson.mailinglist at gmail.com> wrote:


>  OK, reading this again, maybe you mean something more like a Java
> interface?
>

Thinking about it a little more (It's bedtime in my timezone! That's my
excuse!), I think there are two separate things that might be nice to have.
One is an easy way to declare Go-style duck typing interfaces, the other is
an easy way to declare Java-style type checking interfaces. I suppose there
could be two class decorators. Call the first one "interface" and the second
one "typechecking". Interface makes things reply to issubclass with True so
long as they have the same methods and parameters. Typechecking creates a
new class that will raise an error if anything trying to subclass it fails
to use the proper types for input and output.

Do those sounds like useful decorators/metaclasses to have?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110403/e4fb93da/attachment.html>


More information about the Python-ideas mailing list