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@python
components: Documentation
messages: 261000
nosy: docs@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 <[email protected]>
<http://bugs.python.org/issue26458>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com