[Python-Dev] PEP 559 - built-in noop()

Barry Warsaw barry at python.org
Thu Nov 23 10:49:28 EST 2017


On Nov 22, 2017, at 19:32, Victor Stinner <victor.stinner at gmail.com> wrote:
> 
> Aha, contextlib.nullcontext() was just added, cool!

So, if I rewrite PEP 559 in terms of decorators it won’t get rejected?

from functools import wraps

def noop(func):
    @wraps(func)
    def wrapper(*args, **kws):
        return None
    return wrapper


@noop
def do_something_important(x, y, z):
    return blah_blah_blah(x, y, z)


print(do_something_important(1, 2, z=3))

Cheers?
-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171123/a60ceb7a/attachment.sig>


More information about the Python-Dev mailing list