[Types-sig] Keyword arg declarations

Greg Stein gstein@lyra.org
Fri, 17 Dec 1999 06:54:32 -0800 (PST)

On Fri, 17 Dec 1999, Guido van Rossum wrote:
> I just realized that Tim's decl syntax that's currently being bandied
> around doesn't declare the names of arguments.  That's fine for a
> language like C, but in Python, any argument with a name (*args
> excluded) can be used as a keyword argument.
> I think it will be useful for the decl syntax to allow leaving out or
> supplying argument names -- that tells whether keyword arguments are
> allowed for this particular function.  And that is part of a
> function's signature.

Shouldn't be hard to add these names. IMO, the syntax for functions in a
typedecl should look just like the "def" syntax (which should be updated
to allow typedecls).

> (Un)related: I think it makes sense to be able to restrict the types
> of *varargs arguments.  E.g. eons ago (last week in the types-sig)
> someone proposed an extension to isinstance() allowing one to write
> isinstance(x, type1, type2, type3, ...).  Clearly the varargs are all
> type objects here.
> Not so sure about **kwargs, but these should probably be treated the
> same way.

Shouldn't be a problem:

def foo(bar, *args: [Int], **kw: {String: Float}) -> None:


Greg Stein, http://www.lyra.org/