-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
create a decorator for adding default keyword arguments to a function #5405
Comments
comment:1
Attachment: trac_5405.patch.gz Hi Mike! I am not so sure about the name, although I can't propose much better than Could it be generalized to handle both positional and non positional arguments? I'd suggest to have the doc by starting with what the thing actually does, followed by the typical usage. |
comment:3
Oops, should have set the subject to needs work. Done. |
comment:5
Sorry if I don't get this right, but doesn't functools.partial already fulfill this purpose? |
comment:6
Do you mean something like this?
|
comment:7
Actually I meant something like this:
|
comment:8
Cute. Very nice! |
comment:9
So now can you use
|
comment:10
This works, but it certainly isn't obvious:
|
comment:11
and at that point, I'd say
is nicer. However, one might use partial in the above decorator. I think our discussion is evidence for the usefulness of the idea on this ticket. |
comment:12
Yep. It's certainly much clearer. Using |
comment:13
So we've agreed that we should create a
just works as expected. |
comment:14
Perhaps a name of |
comment:15
Thanks much for pointing out functools.partial and functool.wrapper; I have several other use cases for them! Replying to @TimDumol:
I prefer partial, since curry does not really encompass the specialization of named arguments. |
This comment has been minimized.
This comment has been minimized.
comment:16
Fair enough -- but just to clarify, |
Attachment: trac_5405-decorator-partial.patch.gz Adds module |
comment:17
Nevermind, This patch should do the trick. I named it |
comment:18
Looks good to me. |
Author: Tim Dumol |
Reviewer: Mike Hansen |
Attachment: trac_5405-decorator-partial.2.patch.gz same as previous but with username |
comment:19
The patch trac_5405-decorator-partial.2.patch is the same as Tim's patch, but with his username. |
Merged: sage-4.4.2.alpha0 |
comment:20
|
The typical usage of this decorator would be to be applied above a
:obj:
cached_method
or :obj:cached_function
decorator so thatthe correct cached object is returned.
CC: @mwhansen @jasongrout
Component: misc
Author: Tim Dumol
Reviewer: Mike Hansen
Merged: sage-4.4.2.alpha0
Issue created by migration from https://trac.sagemath.org/ticket/5405
The text was updated successfully, but these errors were encountered: