[Python-3000] Draft pre-PEP: function annotations

Paul Prescod paul at prescod.net
Mon Aug 14 22:20:54 CEST 2006

On 8/14/06, Collin Winter <collinw at gmail.com> wrote:
> The way I read this, it forces (more or less) each
> annotation-consuming library to invent new ways to spell Python's
> built-in types.

I think that this is related to your other question. What if an annotation
consuming library wanted to use Python's built-in types nested within their
own top-level structures.

def foo(a: xxx([x, y, z])): ...

I would say that the innermost list has its semantics (as metadata) defined
by "xxx", not raw Python. That's the only reasonable thing.

> "This implies that the interpretation of built-in types would be
> controlled
> > by Python's developers and documented in Python's documentation.
> The inherent difficulty in defining a standard interpretation for
> these types is what motivated me to leave this up to the authors of
> annotation consumers.

There are three issues: first, we need to RESERVE the types for
standardization by Guido and crew. Second, we can decide to do the
standardization at any point. Third, we absolutely need a standard for
multiple independent annotations on a parameter. Using lists is a
no-brainer. So let's do that.

If you have an idea, though, feel free to propose something concrete.

Yes, my proposal is here:

>  "In Python 3000, semantics will be attached to the following types:
> objects
> > of type string (or subtype of string) are to be used for documentation
> > (though they are not necessarily the exclusive source of documentation
> about
> > the type). Objects of type list (or subtype of list) are to be used for
> > attaching multiple independent annotations."
> Does this mean all lists "are to be used for attaching multiple
> independent annotations", or just top-level lists (ie, "def foo(a: [x,
> y])" indicates two independent annotations)? What does "def foo(a: [x,
> [y, z]])" indicate?

I meant only top-level lists. I hadn't thought through nesting.

def foo(a: [x, y, [a, b, c]]): ...

This should probably be just handled recursively or disallowed. I don't feel
strongly either way.

 Paul Prescod
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20060814/ff1b6d61/attachment.html 

More information about the Python-3000 mailing list