An argument (or actual argument) is a value supplied to a function at the call site. In greet("Alice"), the string "Alice" is the argument. Arguments are bound to the function's parameters when the call is made. Python supports both positional arguments (matched by order) and keyword arguments (matched by name, as in greet(name="Alice")).
When Python passes an argument, it passes a reference to the object, not a copy. This is sometimes called "pass by assignment" or "pass by object reference." For immutable objects (integers, strings, tuples), this behaves like pass-by-value because the function cannot modify the original. For mutable objects (lists, dictionaries), changes made inside the function are visible to the caller — which can be either a feature or a source of bugs.
The * and ** operators can be used at the call site to unpack sequences and dictionaries into arguments: f(*[1, 2, 3]) is equivalent to f(1, 2, 3), and f(**{'a': 1, 'b': 2}) is equivalent to f(a=1, b=2). This unpacking mechanism is one of Python's most versatile features, enabling generic wrapper functions and delegation patterns.
Discussed in:
- Chapter 5: Functions — Parameters and Arguments