On Thu, 2 Dec 2021 at 08:29, Paul Moore <p.f.mo...@gmail.com> wrote: > > On Wed, 1 Dec 2021 at 22:27, Greg Ewing <greg.ew...@canterbury.ac.nz> wrote: > > > > On 2/12/21 4:40 am, Paul Moore wrote: > > > the > > > intended use is that people must supply a list[int] or not supply the > > > argument *at all*. > > > > I don't think this is a style of API that we should be encouraging > > people to create, because it results in things that are very > > awkward to wrap. > > Hmm, interesting point, I agree with you. It's particularly telling > that I got sucked into designing that sort of API, even though I know > it's got this problem. I guess that counts as an argument against the > late bound defaults proposal - or maybe even two: > > 1. It's hard (if not impossible) to wrap functions that use late-bound > defaults. > 2. The feature encourages people to write such unwrappable functions > when an alternative formulation that is wrappable is just as good. > > (That may actually only be one point - obviously a feature encourages > people to use it, and any feature can be over-used. But the point > about wrappability stands).
Actually, Chris - does functools.wraps work properly in your implementation when wrapping functions with late-bound defaults? >>> def dec(f): ... @wraps(f) ... def inner(*args, **kw): ... print("Calling") ... return f(*args, **kw) ... return inner ... >>> @dec ... def g(a => []): ... return len(a) Paul _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/M5OHAWF44FRD6OL5F65IDDNKBFL36RUW/ Code of Conduct: http://python.org/psf/codeofconduct/