[Tutor] parameters vs arguments

Modulok modulok at gmail.com
Thu Nov 5 05:58:15 CET 2009


[snip]
> When I define, say, function example like this...
> def example(x,y):
>
> are x and y arguments? or parameters?
>
> And when I call the function and pass it values
>
> example(32,17) are those values arguments or parameters? I *thought* this
> was called 'passing arguments'...
>
> I actually thought x and y would be referred to as arguments in both cases,
> but then sometimes I think I hear them called parameters.
>
> Help? Am I missing some nuances here?
[/snip]

For all practical intents and purposes, they're synonymous. But there
*is* a difference if you want to get technical about it.

As far as the terminology goes, it can depend on the language you're
using. Since a lot of programmers use more than one language, a lot of
terminology gets borrowed across language lines. Strictly speaking the
'parameter' is the variable which stores arbitrary data, that is
addressable within the function body. The specific data being passed,
is the 'argument'. For example:

def foo(arg):
   print arg

foo("spam and eggs")

The variable 'arg' in the function definition would the the
'parameter' and the value "spam and eggs" in the function call would
be an 'argument' to that parameter. ...strictly speaking. In reality,
some language texts may have a preference for one term over the other,
due to the author's background and previous languages they've used.
For all practical intents and purposes, they're synonymous and
frequently used interchangeably.

-Modulok-


More information about the Tutor mailing list