On 2019-11-18 18:09, Samuel Muldoon wrote:
At present, multi-argument function decorators are a little bit
tricky to implement.

As an example (somewhat contrived), suppose that `wait` is a function
 decorator which haults program execution for a few seconds before
calling the wrapped function.

If you do not pass a float value into *delay* then the default value
is 1 second.

        I would say this is a poor design. Just write "wait" so that you always
have to call it, and you just pass no arguments if you want the default.
So instead of this:

# default delay
@wait
def foo():

# custom delay
@wait(2)
def foo():

        . . . you do this:

# default delay
@wait()
def foo():

# custom delay
@wait(2)
def foo():

-- Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is no
path, and leave a trail."
--author unknown
_______________________________________________
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/JXHQFROZQUC6OU2ZMJKIZ2MCENGIC463/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to