Message168356
| Author |
Arvin.Moezzi |
| Recipients |
Arvin.Moezzi |
| Date |
2012年08月16日.08:34:39 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1345106080.5.0.940498216891.issue15683@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I am not sure if this is the right way to do it but IMHO it would be great to
have a function decorator/transformer to make functions partial applicable
using functools.partial. Like
from functools import partial
class partial_applicable():
def __call__(self, func):
def __wrapper(*args, **kvargs):
try:
return func(*args, **kvargs)
except TypeError:
return partial(func, *args, **kvargs)
return __wrapper
Then you could do like:
@partial_applicable()
def substract(left, right):
return left - right
substract(10, 100)
=> -90
rclose = substract(right = 1000)
=> rclose(10) => -990
lclose = substract(1)
=> lclose(10) => -9
What do you think? |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年08月16日 08:34:40 | Arvin.Moezzi | set | recipients:
+ Arvin.Moezzi |
| 2012年08月16日 08:34:40 | Arvin.Moezzi | set | messageid: <1345106080.5.0.940498216891.issue15683@psf.upfronthosting.co.za> |
| 2012年08月16日 08:34:39 | Arvin.Moezzi | link | issue15683 messages |
| 2012年08月16日 08:34:39 | Arvin.Moezzi | create |
|