What is a function parameter =[] for?
Grant Edwards
invalid at invalid.invalid
Wed Nov 18 17:33:11 EST 2015
On 2015-11-18, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Wed, Nov 18, 2015 at 2:08 PM, fl <rxjwg98 at gmail.com> wrote:
>> def eList(val, list0=[]):
> The list0 parameter has a default value, which is [], an initially
> empty list. The default value is evaluated when the function is
> defined, not when it is called, so the same list object is used each
> time and changes to the list are consequently retained between calls.
One might consider this a way to have a local varible inside a
function that's "static" a-la C. However, one probably oughtn't.
--
Grant Edwards grant.b.edwards Yow! Gibble, Gobble, we
at ACCEPT YOU ...
gmail.com
More information about the Python-list
mailing list