Tip 11 Distinguish Parameters and Arguments

Pythonic Programming — by Dmitry Zinoviev (19 / 116)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Mark Dummy Variables | TOC | Avoid “Magic” Values 👉

★2.7, 3.4+ A parameter (or, strictly speaking, a formal parameter) is what the function expects from the caller. Parameters are declared in the function header. Their values are not known until you call the function. The function should be ready to handle or reject any values. A parameter behaves as a local variable (Tip 76, Get the Hang of Local Variables).

An argument (or an actual parameter) is a value that the caller passes to the function. When you call a function, the arguments you pass become the formal parameters’ values as if you stealthily executed several assignment statements.

The two terms are often used interchangeably. I will use them interchangeably, too, as long as it does not cause any ambiguity.

👈 Mark Dummy Variables | TOC | Avoid “Magic” Values 👉

Pythonic Programming by Dmitry Zinoviev can be purchased in other book formats directly from the Pragmatic Programmers. If you notice a code error or formatting mistake, please let us know here so that we can fix it.

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.