On Thu, Dec 02, 2021 at 08:29:58AM +0000, Paul Moore wrote:

> 1. 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
_______________________________________________
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/AHPM6SKTBJZLQBLUYULFPS2K77NJ2LAR/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to