[issue26458] Is the default value assignment of a function parameter evaluated multiple times if it is Parameter=None
Albert Freeman
report at bugs.python.org
Mon Feb 29 05:26:28 EST 2016
New submission from Albert Freeman:
def f(a, L=[]):
L.append(a)
return L
Seems to behave differently to
def f(a, L=None):
L = []
L.append(a)
return L
Which behaves the same as (as far as I noticed) to the below code in the documentation (In the tutorial under 4. More Control Flow Tools)
def f(a, L=None):
if L is None:
L = []
L.append(a)
return L
I am using CPython 3.5.1, what is the point of "if L is None:" in the lowermost above example? And why is None treated differently to []?
----------
assignee: docs at python
components: Documentation
messages: 261000
nosy: docs at python, tocretpa
priority: normal
severity: normal
status: open
title: Is the default value assignment of a function parameter evaluated multiple times if it is Parameter=None
versions: Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26458>
_______________________________________
More information about the Python-bugs-list
mailing list