[Python-3000] Draft pre-PEP: function annotations (original) (raw)

Collin Winter collinw at gmail.com
Thu Aug 10 04:58:55 CEST 2006


On 8/9/06, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

Collin Winter wrote: > one library might use string-based annotations to provide > improved help messages, like so: > > def compile(source: "something compilable", > filename: "where the compilable thing comes from", > mode: "is this a single statement or a suite?"): > > Another library might be used to provide typechecking for Python > functions and methods. > > def sum(*vargs: Number) -> Number: > ...

And what are you supposed to do if you want to write a function that has improved help messages and type checking?

I already answered this in my response to Talin.

The next draft will address this directly.

> The difficulty inherent in writing annotation interpreting > libraries will keep their number low and their authorship in the > hands of people who, frankly, know what they're doing.

Even if there are only two of them, they can still conflict.

No-one is arguing that there won't be conflicting ideas about how to spell different annotation ideas; just look at the number of interface/role/typeclass/whatever implementations.

The idea is that each developer can pick the notation/semantics that's most natural to them. I'll go even further: say one library offers a semantics you find handy for task A, while another library's ideas about type annotations are best suited for task B. Without a single standard, you're free to mix and match these libraries to give you a combination that allows you to best express the ideas you're going for.

Collin Winter



More information about the Python-3000 mailing list