What is a function parameter =[] for?

BartC bc at freeuk.com
Thu Nov 19 19:11:25 EST 2015


On 19/11/2015 22:55, Michael Torrie wrote:
> On 11/19/2015 02:21 PM, BartC wrote:
>> (Python returns 42; so that means my languages are more dynamic than
>> Python? That's hard to believe!)
>
> It tells me your language does late binding for default arguments, which
> does mean the default argument can dynamically change at call time,
> which would surprise me if I didn't know about it.  Either form of
> binding is acceptable, and I don't think it makes a language more or
> less dynamic.

You get the expression that is specified, which can give different 
values at different times unless it involves only constants.

It can't be exactly the same as writing an identical expression in place 
of the missing argument, as apparently different scopes come into play 
if names are involved.

However I mainly use them for constant values. And [] is a constant 
value in my opinion.

-- 
Bartc



More information about the Python-list mailing list