Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99216
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) |
| Date | 2015-11-22 04:02 +1100 |
| Message-ID | <mailman.41.1448125341.2291.python-list@python.org> (permalink) |
| References | <CAPTjJmpwjWnF=d6mpgbKS1biVLoR4APutgyH0n9t6CJ=Kh4dCg@mail.gmail.com> <CAFpSVpJ1MOaH=V9wxzgzkRzrSG0YoKQk7WQ4Fo1K5fd0QLPBuQ@mail.gmail.com> <CAPTjJmpP2j4v4DiY_wdp70rcTCFkjkXpkp9J4UhDZ388Lxvq+w@mail.gmail.com> <CALwzidkaASG257RsygKUF1FRnHtttK8Q3pkvPEW34YPn80QSpg@mail.gmail.com> |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
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
csiph-web