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

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Thu Aug 10 09:28:12 CEST 2006


Hi,

Collin Winter wrote:

def compile(source: "something compilable", filename: "where the compilable thing comes from", mode: "is this a single statement or a suite?"): ...

def sum(*vargs: Number) -> Number: ...

Admittedly, I'm not so much in the "Spring stew" discussion, but I'm not a big fan of cluttering up my function signature with "make them short to make them fit" comments.

What would be wrong in adding a standard decorator for this purpose? Something like:

@type_annotate("This is a filename passed as string", filename = str) @type_annotate(source = str) def compile(source, filename, mode): ...

or, more explicitly:

@arg_docstring(filename = "This is a filename passed as string") @arg_type(filename = str) @arg_type(source = str) def compile(source, filename, mode): ...

Stefan



More information about the Python-3000 mailing list