Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99216 > unrolled thread

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

Started byChris Angelico <rosuav@gmail.com>
First post2015-11-22 04:02 +1100
Last post2015-11-22 04:02 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Chris Angelico <rosuav@gmail.com> - 2015-11-22 04:02 +1100

#99216 — Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

FromChris Angelico <rosuav@gmail.com>
Date2015-11-22 04:02 +1100
SubjectRe: Late-binding of function defaults (was Re: What is a function parameter =[] for?)
Message-ID<mailman.41.1448125341.2291.python-list@python.org>
On Sun, Nov 22, 2015 at 2:01 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
>> and then the decorator could wrap the function. I'm not entirely sure
>> I could implement it reliably, but even leaving that aside, having to
>> put "lambda:" in front of everything is pretty ugly.
>
> Note that "lambda: []" can also be spelled "list".

In that particular example, yes. I kept it in the large form to
maintain the parallel with the version I was quoting. But if the
decorator were to be written, it would probably be something along the
lines of "if the default is callable, do the late-binding magic", so
'list' would work just fine.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web