[Python-3000] Type annotations: annotating generators
Guido van Rossum
guido at python.org
Fri May 19 22:33:59 CEST 2006
On 5/19/06, Collin Winter <collinw at gmail.com> wrote:
> I'll concede that callbacks aren't often invoked in the foo(4, 5, c=7)
> style (so requiring certain parameter names is off the table), but
> I'll in turn push back on varargs and varkw parameters.
>
> I see these as being genuinely useful in higher-order functions,
> especially functions that take a variable-length constructor (like
> list, dict, etc).
I'm unconvinced. Can you provide an example of where this would be
useful? I'm not looking for an example showing how it works; I want to
see an example showing why we need this functionality.
> Since we're no longer using Function()'s keyword
> arguments to make assertions about parameter names, we can eliminate
> the ugliness of star() and double_star() by having *varargs and
> **varkw parameters grab their types from keyword arguments. That is,
>
> def foo(a: Sequence, b: Number, *varargs: Number, **varkw: Number)
>
> would be approved by
>
> Function(Sequence, Number, varargs=Number, varkw=Number)
Maybe. But then I think we also should use this style to add
returns=Number instead of Function().returns(Number).
> The excess argument parameters would be the only ones addressable with
> keyword arguments (vargs and kwargs or varargs and varkw, makes no
> difference to me). These arguments would have to be passed as
> keywords, thus making explicit your intention to use excess positional
> and/or keyword arguments.
Show me the motivating example.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list