Shared publicly  - 
i can't hold back anymore. python is truely idiotic.

in python, you can define a function with unspecified number of unnamed keyword parameters

like this:

# -*- coding: utf-8 -*-
# python

# use 「**‹name›」 to receive unspecified number of keyword arguments
def ff(**ddd):
    # ddd is received as a dictionary
    return ddd

print ff( z = 8, c = 7, aa = 4, b = 3) # {'aa': 4, 'c': 7, 'z': 8, 'b': 3}

but, why'd anyone want to do that? No language i know of that lets one define, read:

 unspecified number
 but Named parameters

But let's say we do need it. But in that case, just pass one dictionary!

that's much simpler.

what's more, is that python also lets you define unspecified number of positional parameters, as well as keyword parameters, as well as any of all the above mixed.

Wow, more power to the coder. But, really? It gets very hairy. Each way you define them, your function receives the arg in different way. You function may need to process a n-tuple data type, or hash table. Also, in the definition, the parameter needs to be in a particular order.

so, in summary, the syntax is complex, each case has a special form, and the semantics is complex, each case your function body need to process the args in a different way.

complexer and complexer.

really, positional param and keyword param is sufficient. When needed, programer can pass list or hash table. That really solves all problems, yet without introducing any complexity to the lang's syntax & semantics.

Python: Function with Optional Parameter, Named Parameter, Infinite Parameters
The following is a example of defining a function. # -*- coding: utf-8 -*- # python def ff(x, y): """ff(x, y) returns x+y.""" return x+y print ff(3,4) # prints 7. A string immediately following the function def line is the function's documentation. return is optional.
Nick Alcock's profile photoLuke McCarthy's profile photoXah Lee's profile photo
Welcome to featuritis city! And yes, if your function uses all those at once it is a nightmare. In Python you basically have to trust your callers as well as the functions you call -- but then, that's the essence of Python's object model anyway (and of things like variables springing into existence on first assignment). Given how trusting it is it's amazing how few horrific bugs there are in Python code...
There are a few cases where it's useful, for example writing "wrapper" functions that pass all arguments and keyword arguments to another function without having to know anything about the function being wrapped (this is often used in decorators). Another use is passing on arguments to a superclass constructor within a subclass constructor without the subclass knowing the arguments (and new ones could be added to the superclass without modifying the subclass). Although often it's just syntactic sugar instead of passing a list or dict, and I agree it is overcomplexifying the semantics of function calls.
Using func(*args, **kwargs) can be seen as a more fancy/sugary version of the 'apply' function in Lisp.
Add a comment...