Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Terry Reedy Newsgroups: comp.lang.python Subject: Re: What is a function parameter =[] for? Date: Tue, 24 Nov 2015 12:46:36 -0500 Lines: 42 Message-ID: References: <564dbe6b$0$1610$c3e8da3$5496439d@news.astraweb.com> <564df258$0$1604$c3e8da3$5496439d@news.astraweb.com> <564e71f6$0$1619$c3e8da3$5496439d@news.astraweb.com> <56547567.2090603@rece.vub.ac.be> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de zd5dmWoUs5K/qyfocoGjOQGLpKPWU0bnptnx4irPn3Ow== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'expressions': 0.07; 'instance.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'jan': 0.11; 'def': 0.13; 'argument': 0.15; 'object()': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'wrote:': 0.16; 'language': 0.19; 'so.': 0.22; 'object.': 0.22; 'recognize': 0.22; 'pass': 0.22; 'trying': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'discussion': 0.24; 'header:User-Agent:1': 0.26; '(which': 0.26; 'header:X-Complaints-To:1': 0.26; 'point.': 0.27; 'function': 0.28; 'convince': 0.29; 'objects': 0.29; 'tutorial': 0.29; "i'm": 0.30; 'compiled': 0.32; 'continuing': 0.32; 'operate': 0.32; 'maybe': 0.33; 'replaced': 0.35; 'something': 0.35; 'should': 0.36; 'instead': 0.36; 'there': 0.36; 'received:71': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'agree': 0.37; 'received:org': 0.37; 'aspects': 0.37; 'creation': 0.38; 'wrong': 0.38; 'why': 0.39; 'sure': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'some': 0.40; 'him': 0.60; 'your': 0.60; 'behavior': 0.61; 'default': 0.61; 'here.': 0.62; 'goal': 0.64; 'hoping': 0.77; 'you:': 0.79; "'object'": 0.84; 'pardon': 0.84; 'schreef': 0.84; 'received:fios.verizon.net': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: pool-71-185-227-36.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: <56547567.2090603@rece.vub.ac.be> 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:99374 On 11/24/2015 9:34 AM, Antoon Pardon wrote: I agree that the tutorial should talk about default argument objects (which have values) instead of conflating 'object' with 'value'. > Op 20-11-15 om 13:12 schreef Ned Batchelder: >> I'm not sure what your goal is at this point. Are you: >> >> 1) still unsure what the behavior is, or >> 2) trying to understand why it behaves that way, or >> 3) hoping to change Python, or >> 4) trying to convince us that your language is better, or >> 5) something else? > > Maybe just have us recognize that some aspects of python indeed are bizarre. The current behavior under discussion is: default argument expressions are evaluated once at function creation time to produce default argument objects that are bound to the function object. I do not see this as bizarre. > That there is nothing wrong with him thinking so. I do recognize that some would prefer that default argument expressions be treated differently, that def f(a=expression): pass be compiled to operate as the following does now def f(a=None): a = a if a is not None else expression perhaps with None replaced with a hidden object() instance. I find the continuing fuss over the choice that was made to be the bizarre thing here. -- Terry Jan Reedy