liveBook · Manning

Function argument

As explained in The Well-Grounded Python Developer: How the pros use Python and Flask

An argument is a value supplied to a function or method when it is called.

A function argument is a value supplied when a function or method is called. The function receives that value through a parameter, the name defined in its interface. section 3.1.2

Arguments can be positional or keyword-based. Their order and names form part of an API’s contract, so clear calls make code easier to use and maintain. section 3.1.2

Passing one or several values

Calling print("Hello World") passes one argument. Calling print("Hello", "World") passes two positional arguments, which print outputs with its default space separator. section 3.1.2

print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)

Inspect print’s signature to see its positional object arguments and configurable keyword arguments, including sep, end, file, and flush. section 3.1.2

How The Well-Grounded Python Developer: How the pros use Python and Flask covers it

How deep it goes
Defines arguments and parameters, then demonstrates positional, keyword, variadic, and default arguments through print.
Examples
Uses print calls with one or multiple strings and examines the print signature’s sep, end, file, and flush parameters.
What it assumes
Assumes familiarity with calling functions and introduces the distinction between supplied arguments and defined parameters.
What you can do after
Apply it via Python function calls to pass values positionally or by keyword and customize print output.
How it connects
Connects arguments with functions, methods, parameters, APIs, positional parameters, and keyword parameters.

Also explained in

Compare how 5 books explain function argument →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Python Developer: How the pros use Python and Flask. The section links point to the parts of the book it draws on.