Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: What is a function parameter =[] for? Date: Fri, 20 Nov 2015 18:31:50 +0200 Organization: A noiseless patient Spider Lines: 28 Message-ID: <87vb8wd43t.fsf@elektro.pacujo.net> 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="21197"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4HHNTUKv7bdCCCUe/hgO/" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:baHNdnu/Te25L7qWCw7SM3Ly4Ec= sha1:BTugDUDWQ5r4ZEDoV4rw8+rIW2Q= Xref: csiph.com comp.lang.python:99165 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 Marko