Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'context': 0.04; 'parameter': 0.05; 'does.': 0.07; 'nasty': 0.07; 'argument,': 0.09; 'modifies': 0.09; 'argument': 0.15; 'alex23': 0.16; 'definition.': 0.16; 'duplicates': 0.16; 'guard': 0.16; "he'll": 0.16; 'irrelevant,': 0.16; 'sees': 0.16; 'subject:=': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.24; 'code': 0.25; 'code.': 0.26; "i'm": 0.26; 'function': 0.27; 'message-id:@mail.gmail.com': 0.28; "he's": 0.29; 'likes': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; '22,': 0.30; 'concern,': 0.30; 'thu,': 0.32; 'list': 0.32; 'points': 0.34; 'received:209.85.212': 0.34; 'assignment': 0.34; 'list.': 0.35; 'joe': 0.35; 'but': 0.37; 'received:google.com': 0.37; 'several': 0.38; 'received:209.85': 0.38; "it's": 0.40; 'received:209': 0.40; '2011': 0.61; 'matter': 0.61; 'your': 0.61; 'afraid': 0.63; 'dangerous': 0.64; 'immediate': 0.65; 'what,': 0.67; 'million': 0.76; 'camps': 0.84; 'irrelevant': 0.84; 'surprise': 0.97 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=UBwLLK+pSmVQKAjNSByu5BWXfAN5rAYBi/FtxuJp4ic=; b=SsFgvxOA7X07X1hSEICstFq7N6BjhgaPyxEijN/FFK5JsWpwgMCpIMuS6SFVq0bRO9 2lQgigNmV2xSlTx/UfCNbiCZI+OneZudnoLYBOv3e+dhysTdBIa873+hGWjPFqlEKZrZ 0Gt4n+vxoE9xjvEOGhWsVTi/KeoXE1dP7XvMI= MIME-Version: 1.0 In-Reply-To: References: <18f78d0d-1e70-4c7b-9033-1422e6edb6db@t13g2000yqg.googlegroups.com> <10c62dac-2750-4f08-8962-21952c1c0a0b@v31g2000prg.googlegroups.com> From: Ian Kelly Date: Thu, 22 Dec 2011 19:59:06 -0700 Subject: Re: what does 'a=b=c=[]' do To: alex23 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324609184 news.xs4all.nl 6943 [2001:888:2000:d::a6]:52430 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17768 On Thu, Dec 22, 2011 at 7:10 PM, alex23 wrote: > On Dec 22, 6:51=A0pm, Rolf Camps wrote: >> I'm afraid it's dangerous to encourage the use of '[]' as assignment to >> a parameter in a function definition. If you use the function several >> times 'default' always points to the same list. > > I appreciate the concern, but adding a default argument guard would > not only obscure the code. It's irrelevant, as you recognise, because > no matter what, it's going to make copies of the default argument. It's only irrelevant in the immediate context of the code you posted. But when Joe Novice sees your code and likes it and duplicates it a million times without receiving any warning about it, he's eventually going to write a function that modifies its default list argument, and he'll be in for a nasty surprise when he does.