"Daiyue Weng" <daiyuew...@gmail.com> a écrit dans le message de news:mailman.208.1475840291.30834.python-l...@python.org...
Hi, I declare two parameters for a function with default values [],

def one_function(arg, arg1=[], arg2=[]):

PyCharm warns me:

Default argument value is mutable,

what does it mean? and how to fix it?

cheers

You could ignore this warning if you know what you
are doing, imho.
The default value being mutable it is possible to change
it inside the function. eg:

def test(x=[0]):
... print(x)
... x[0] += 1

test()
[0]

test()
[1]




--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to