Stefan Behnel wrote:
> 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):
>       ...

Ah, never mind, that only applies to docstrings. The type annotation would not
be available to the compiler...

So, it would be a good idea to split the two: docstrings and types. Where a
decorator provides a readable (and extensible) solution for the first, type
annotations should be part of the signature IMHO.

Stefan

_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to