Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; 'arguments': 0.09; 'booth': 0.09; 'executed': 0.09; 'received:internal': 0.09; 'subject:set': 0.09; 'def': 0.12; '(lambda': 0.16; 'block.': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'parameter.': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:66.111.4.27': 0.16; 'received:messagingengine.com': 0.16; 'received:out3-smtp.messagingengine.com': 0.16; 'subject:default': 0.16; 'subject:parameters': 0.16; 'subject:their': 0.16; 'subject:values': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'previously': 0.22; 'compiled': 0.26; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'dec': 0.30; 'statement': 0.30; 'code': 0.31; 'once,': 0.31; 'received:66': 0.35; 'created': 0.35; 'false': 0.36; 'subject:?': 0.36; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'from:no real name:2**0': 0.61; 'header:Message-Id:1': 0.63; 'more': 0.64; 'default': 0.69; 'subject:get': 0.81; '2014,': 0.84 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:x-sasl-enc:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=mesmtp; bh=ynt8BoDMzNR0L6f30rbT95SCf8M=; b=spGs l5zaEj9ElDYIDLtDRWqQe00lJVV9uLrTFLhQ7D59igsS7VcXibpTx0hvL1tQatlJ e3eqPtrV/K8fBEKoM7QD0dtT7xn1LsXF9fqdTejZYDZEGYcpUzLeNL//AitAuweH VL4hH6r4XMzoZWyecm8lwhtR2F9ITkuM+TMlrrg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:x-sasl-enc:from:to :mime-version:content-transfer-encoding:content-type:in-reply-to :references:subject:date; s=smtpout; bh=ynt8BoDMzNR0L6f30rbT95SC f8M=; b=P+uNCsCBZqe1ktaV1LlYI9b+kxTyBg5YAQzgmltbH7ZxDwOxkVxkzEYC JRJ+W6IlS4FjFSkWL1ViuPGKe6GuQPriMRK83ZptNWtZQOT/QARYvYHLXNDDBR7c FoFeoQoZTEQG7c7HXBgjh3d7ZCWDqo0n0UU5WBDtNRqjjg9eJ8s= X-Sasl-Enc: Tcxnwm49Gvqm7ZlAotiWYx+Uy31s0WFHEOox5m1JCcgS 1418166473 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-0d23237d In-Reply-To: References: <54866F2E.1765.complang@piz.noip.com> <54866F2E.1768.complang@piz.noip.com> Subject: Re: When do default parameters get their values set? Date: Tue, 09 Dec 2014 18:07:53 -0500 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418166477 news.xs4all.nl 2952 [2001:888:2000:d::a6]:57772 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 4222 X-Received-Body-CRC: 2011201624 Xref: csiph.com comp.lang.python:82242 On Tue, Dec 9, 2014, at 16:18, Duncan Booth wrote: > The default parameters are actually evaluated when the 'def' statement is > executed and the function object is created from the default arguments > and > the previously compiled code block. Which means that if you execute the def statement [or lambda] more than once, you will get more than one instance of the default parameter. >>> def f(): return (lambda x={}: x) ... >>> f()() is f()() False >>> g = f() >>> g() is g() True