Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: What is a function parameter =[] for? Date: Thu, 19 Nov 2015 13:15:29 +1100 Lines: 31 Message-ID: References: <85k2ped9le.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de 5gGdYn1tOKpjrgg84XvO9QPapB2ggN64y+qnLZKcTs0A== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; '[],': 0.07; 'remaining': 0.07; 'cc:addr:python-list': 0.09; 'mutable': 0.09; 'argument': 0.15; 'thu,': 0.15; 'value.': 0.15; '"value"': 0.16; '(barring': 0.16; '1:08': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'such,': 0.16; 'wrote:': 0.16; '>>>': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'interpret': 0.22; 'object.': 0.22; 'header:In-Reply-To:1': 0.24; 'point.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'initial': 0.28; 'objects': 0.29; 'compared': 0.30; 'normally': 0.30; '"the': 0.32; 'retain': 0.33; 'values.': 0.33; 'equal': 0.34; 'received:google.com': 0.35; 'false': 0.35; 'identity': 0.35; 'nov': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'mean': 0.38; 'default': 0.61; 'state,': 0.66; 'guaranteed': 0.67; 'quality': 0.72; 'chrisa': 0.84; 'to:none': 0.91; 'hand,': 0.97 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=C4n4dUSLfW3St0noaF0USlfYsxsjfGAEBwxws0NvsmU=; b=d6zisDigdBF0xeNLaWwg/MvhfXPV0ZduefjinIcDdvx9qqCU47f37mx1GIFmfRwcbs SCePlK5SMPyTIYyaBUFlUyiBI4wCnUtFQP0AybbTR9wkgOGw/nryLcm4rDXX0ecCjvxu VdzU0XgW5lIXgNMq0yshtqguV+KcTiaovT5bFjxTcV28f2ZGM/1nRRCsavToUbdTcc/G rsvHytUGRb6iVlhBmPuiTnwBjnebHJSCCjf1A66UOSEhoJ3zVpHf8KJvp34KZhxkr4oP 4RoLXfaPqDm0sZep9PCJZwfl7ZgjpnBhtZhLyJeEkAwuApyiud7XJ9dLt1Vkouk+wwhr 0AWg== X-Received: by 10.107.10.233 with SMTP id 102mr6103965iok.31.1447899329286; Wed, 18 Nov 2015 18:15:29 -0800 (PST) In-Reply-To: <85k2ped9le.fsf@benfinney.id.au> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:99027 On Thu, Nov 19, 2015 at 1:08 PM, Ben Finney wr= ote: >> Nope. Mutable objects are never guaranteed to retain the same values. >> That's kinda the point. > > Well, they are the *same value*, if by =E2=80=9Cvalue=E2=80=9D you mean = =E2=80=9Ca particular > object=E2=80=9D. > > On the other hand, the value can *change* over time, while remaining the > same object. So it will not be equal to its initial state, even though > it is the same object. I would normally interpret "value" as "the quality compared with the =3D=3D operator". As such, mutables can change in value while retaining their identities: >>> x, y =3D [], [] >>> x =3D=3D y True >>> x.append(1) >>> x =3D=3D y False >>> y.append(1) >>> x =3D=3D y True So a mutable default argument will always retain its identity (barring shenanigans), but may not retain its value. ChrisA