Message261000
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 []? |
|
Date |
User |
Action |
Args |
2016-02-29 10:26:28 | tocretpa | set | recipients:
+ tocretpa, docs@python |
2016-02-29 10:26:28 | tocretpa | set | messageid: <1456741588.21.0.674537261973.issue26458@psf.upfronthosting.co.za> |
2016-02-29 10:26:28 | tocretpa | link | issue26458 messages |
2016-02-29 10:26:27 | tocretpa | create | |
|