What is a function parameter =[] for?

Antoon Pardon antoon.pardon at rece.vub.ac.be
Tue Nov 24 07:48:25 EST 2015


Op 24-11-15 om 13:07 schreef Chris Angelico:
> On Tue, Nov 24, 2015 at 10:36 PM, Antoon Pardon
> <antoon.pardon at rece.vub.ac.be> wrote:
>>>> So, looking at some source code, a default value for certain types is only
>>>> certain to be that value for the very first call of that function?
>>>
>>> On the contrary, it is certain always to be that exact object.
>>
>> No, he is talking about the value. Since the object can be mutated
>> and thus have an other value, his statement seems correct.
> 
> With mutable objects, you can *never* depend on their values. Any time
> ANY byte code gets executed, the value could change. That's why I have
> never said anything about *values* of arg defaults.

Yes you have. You haven't mentioned them yourself. But when you contradict
the statement of someone and that person talked about values, then in
contradicting that statement you said something about values.

You then switching to talking about objects, just gives the impression
that object is a synonym for value.

-- 
Antoon



More information about the Python-list mailing list