What is a function parameter =[] for?

Ian Kelly ian.g.kelly at gmail.com
Wed Nov 18 19:52:33 EST 2015


On Wed, Nov 18, 2015 at 5:34 PM, fl <rxjwg98 at gmail.com> wrote:
> After I try with
>
> list1 = eList(12, [2])
>
> and
>
> list1 = eList(12)
>
> it gives me new surprises. Even though I delete list1, the subsequent
> list1 = eList(12)
> will remember the number of '12' of the previous sequence. This is my new
> question: What does 'del' do? It does not look like a thorough list deletion
>  from the effect.

It just deletes the variable list1, i.e. it unbinds the value from the
name. It does nothing at all to the list that was bound, as other
variables may still be bound to it.

The core issue is that the default value of your eList function is
always the same list. Assigning that list to a variable and then
unassigning it is not going to change that.



More information about the Python-list mailing list