This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tocretpa
Recipients docs@python, tocretpa
Date 2016-02-29.10:26:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1456741588.21.0.674537261973.issue26458@psf.upfronthosting.co.za>
In-reply-to
Content
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 []?
History
Date User Action Args
2016-02-29 10:26:28tocretpasetrecipients: + tocretpa, docs@python
2016-02-29 10:26:28tocretpasetmessageid: <1456741588.21.0.674537261973.issue26458@psf.upfronthosting.co.za>
2016-02-29 10:26:28tocretpalinkissue26458 messages
2016-02-29 10:26:27tocretpacreate