
2 Dec
2021
2 Dec
'21
1:47 a.m.
On Thu, Dec 02, 2021 at 08:29:58AM +0000, Paul Moore wrote:
- It's hard (if not impossible) to wrap functions that use late-bound
defaults.
I don't understand that argument.
We can implement late-bound defaults right now, using the usual sentinel jiggery-pokery.
def func(spam, eggs, cheese=None, aardvark=42): if cheese is None: ... # You know the drill.
We can wrap functions like this. You don't generally even care what the sentinel is. A typical wrapper function looks something like this:
@functools.wraps(func) def inner(*args, **kwargs): # wrapper implementation func(*args, **kwargs)
with appropriate pre-processing or post-processing as needed.
Why would argument unpacking to call the wrapped function stop working?
--
Steve