Variadic function: Difference between revisions

Content deleted Content added
Line 48:
{{section-stub}}
 
Python supports very flexible variadic functions. By marking variables with one asterisk (e.g. *var) the given variable is defined to be a tuple of all the extra arguments. By marking variables with two asterisks (e.g. **var) the given variable is a dictionary of all extra [[http://en.wikipedia.org/wiki/Parameter_(computer_science) | keyword arguments]]; the keys are strings, which are the names that were . Conventionally these are called "args" and "kwargs" respectively, but they may be something else, and packages often make good use of this ability to improve readability (e.g. [[BeautifulSoup | http://www.crummy.com/software/BeautifulSoup/documentation.html BeautifulSoup]]). If they exist, these arguments must be the last one in the list.
 
def f(*args, **kwargs):