-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add apply
#411
Add apply
#411
Conversation
I am +1 because this is generally useful and is duplicated in a lot of code; however, I somewhat object to the phrase "clojure-like": https://docs.python.org/2/library/functions.html#apply. Still very Pythonic. |
Yeah, I agree this is common enough to justify being added. It's unfortunate that What about something like this: def apply(*func_and_args, **kwargs):
if not func_and_args:
raise TypeError('func argument is required')
return func_and_args[0](*func_and_args[1:], **kwargs) |
@eriknw Agree and updated |
apply
functionapply
function
@eriknw ready to merge as far as I'm concerned |
This is in, thanks @eliasmistler! (and sorry for the delay) |
Just a remark perhaps for future reference, as of Python 3.8 the signature could be simplified once more by use of the positional only indicator: def apply(func, /, *args, **kwargs):
return func(*args, **kwargs)
def test_no_keyword_clash(x, func):
return x+func
apply(test_no_keyword_clash, x=1, func=2) |
No description provided.