A question on modification of a list via a function invocation
Steve D'Aprano
steve+python at pearwood.info
Wed Aug 16 21:47:27 EDT 2017
On Thu, 17 Aug 2017 11:07 am, Stefan Ram wrote:
> Steve D'Aprano <steve+python at pearwood.info> writes:
>>On Thu, 17 Aug 2017 08:29 am, Mok-Kong Shen wrote:
>>>In the first case, any modification of the formal parameter
>>Technically, you cannot modify the formal parameter, because the formal
>>parameter is just a name unbound to any value. It's just the label in the
>>function definition. You need to have actually passed a value as argument to
>>the function before there is anything to modify.
>
> So, when an argument is actually passed, then the parameter
> can be modified? It seems Mok-Kong Shen was writing about
> this case.
I would say that the argument is modified.
https://docs.python.org/3/faq/programming.html#faq-argument-vs-parameter
"Parameters are defined by the names that appear in a function definition,
whereas arguments are the values actually passed to a function when calling
it."
See also:
https://docs.python.org/3/glossary.html#term-parameter
https://docs.python.org/3/glossary.html#term-argument
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list