Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: What is a function parameter =[] for? Date: Fri, 20 Nov 2015 09:39:10 -0700 Lines: 28 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> <877flcrh26.fsf@elektro.pacujo.net> <87vb8wd43t.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de TT8lu9oZBMhAgKAk3naOLgx+KG56f1UE7+0+Y1/VGTdQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.029 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'def': 0.13; 'explicitly': 0.15; 'value.': 0.15; 'omitted,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'self._name': 0.16; 'sentinel': 0.16; 'values:': 0.16; 'wrote:': 0.16; "shouldn't": 0.18; 'language': 0.19; '>>>': 0.20; '2015': 0.20; 'pass': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'data,': 0.27; 'values': 0.28; 'argue': 0.29; 'omitted': 0.29; 'url:wikipedia': 0.29; 'allows': 0.30; 'url:wiki': 0.30; 'values.': 0.33; 'received:google.com': 0.35; 'could': 0.35; 'nov': 0.35; 'but': 0.36; 'should': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'possible': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'why': 0.39; 'url:en': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'ever': 0.60; 'default': 0.61; 'between': 0.65; '20,': 0.66; 'distinguish': 0.84; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=UEnMXe9Ls9y7IrfD/dTsD91NNS0BQJdHOKabJep3Icg=; b=Dp773vxFNQ1FnLx+abeZd8j7IxNF+QfVdBkB6w281SXvifkANXX2lLdk4UCkmnK2Lb BYjXYCZPUz2KW8ySnTb3SRua8lksiUtXS7dyoZcCPIan21WoS9nRLnDucVNg29h7ug09 lSPQj5xB2RMxZdfDaEILjvCl8bzei25JL1cl1UsloEp9tVSLmthUb5B86ywRqXW2JJcT JNg+D7tLx3Kfbq3u38VK2kBpFWHmxTkL01OyKHnew35F1foc7fPeQIVmiaqwcOx20B4c Y3+9/ipLi7yUt72TYtsFkWkN0u8SJqYnAr9pQmA9MHqL3jyLvnv9EF14seCH2u7MDsIV Pbkg== X-Received: by 10.50.12.42 with SMTP id v10mr2741812igb.85.1448037589975; Fri, 20 Nov 2015 08:39:49 -0800 (PST) In-Reply-To: <87vb8wd43t.fsf@elektro.pacujo.net> 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:99168 On Fri, Nov 20, 2015 at 9:31 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Fri, Nov 20, 2015 at 5:28 AM, Marko Rauhamaa wrote: >>> One could argue that you should always use a sentinel object for >>> default values. That also allows you to distinguish between omitted >>> values and default values: >>> >>> def asklist(caption, data, n=omitted, rows=omitted, width=omitted, >>> flags=omitted, buttons=omitted, tablist=omitted, >>> heading=omitted): >>> >>> but that would be rather pedantic in most circumstances. >> >> I think that would be bad design; in general, you shouldn't *need* to >> distinguish whether the value was omitted, because it should always be >> possible to explicitly pass the default value. > > Consider the mutator pattern: > > def name(self, value=omitted): > if value is omitted: > return self._name > self._name = value > > Why would you ever want to do this in a language with properties?