|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
parameters vs argumentsI'm just starting to learn Python, and some of the vocabulary has me a bit confused. I was hoping someone could help me out. People were so helpful last time!
I'm reading stuff from multiple sources, and it seems to me like the words "parameters" and "arguments" are used interchangeably. But I'm not sure if this is a wrong perception, due to my lack of understanding, or if these terms are truly synonyms. 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? Thanks for reading! -Kris _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: parameters vs argumentsOn Wed, Nov 4, 2009 at 8:08 PM, Kristin Wilcox <wilcoxwork@...> wrote:
> I'm reading stuff from multiple sources, and it seems to me like the words > "parameters" and "arguments" are used interchangeably. But I'm not sure if > this is a wrong perception, due to my lack of understanding, or if these > terms are truly synonyms. Wikipedia has a nice description: http://en.wikipedia.org/wiki/Parameter_%28computer_science%29#Parameters_and_arguments Short view - technically, parameters are the variables in the function and arguments are the values given to the variables at the point of call. So outside the function, it is more common to talk about arguments. Inside the function, you can really talk about either. > When I define, say, function example like this... > def example(x,y): > > are x and y arguments? or parameters? Parameters that will take on the value of the arguments passed to the function. > 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'... 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? Not really, it is not an important distinction. Kent _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: parameters vs arguments[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? 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- _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: parameters vs arguments"Kristin Wilcox" <wilcoxwork@...> wrote > I'm just starting to learn Python, and some of the vocabulary has me a > bit > confused. FWIW I take great care in my tutor to highlight and explain the terminology of programming in my tutor. I italicise new words and explain them on first use. So it might be useful taking a look there if you find areas of confusion. > I'm reading stuff from multiple sources, and it seems to me like the > words > "parameters" and "arguments" are used interchangeably. This is a confusing one and people often do get them mixed up. Basically a parameter is what you call the thing used in the function definition. An argument is whats used when you call the function. Thus, at invocation, the parameter takes on the value of the argument. This is confused futher by some text books using the term "formal argument" instead of parameter. When you see "formal argument" it does just mean a parameter. Fortunately this usage is rare nowadays. > When I define, say, function example like this... > def example(x,y): > > are x and y arguments? or parameters? 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'... arguments HTH -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: parameters vs argumentsParameter is what used to give/call value in function.
Argument is what used to give/call value in command line interface. Am I correct??... Binto -----Original Message----- From: tutor-bounces+binto=triplegate.net.id@... [mailto:tutor-bounces+binto=triplegate.net.id@...] On Behalf Of Alan Gauld Sent: Thursday, November 05, 2009 2:08 PM To: tutor@... Subject: Re: [Tutor] parameters vs arguments "Kristin Wilcox" <wilcoxwork@...> wrote > I'm just starting to learn Python, and some of the vocabulary has me a > bit > confused. FWIW I take great care in my tutor to highlight and explain the terminology of programming in my tutor. I italicise new words and explain them on first use. So it might be useful taking a look there if you find areas of confusion. > I'm reading stuff from multiple sources, and it seems to me like the > words > "parameters" and "arguments" are used interchangeably. This is a confusing one and people often do get them mixed up. Basically a parameter is what you call the thing used in the function definition. An argument is whats used when you call the function. Thus, at invocation, the parameter takes on the value of the argument. This is confused futher by some text books using the term "formal argument" instead of parameter. When you see "formal argument" it does just mean a parameter. Fortunately this usage is rare nowadays. > When I define, say, function example like this... > def example(x,y): > > are x and y arguments? or parameters? 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'... arguments HTH -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |