3 ms·
I find this[1] example in Getting Started/Next Steps to be backwards: # incomplete partial: add(?, 2) >>> s2 = add.s(2) # resolves the partial: ad
by simonpantzare 14y ago
I find this[1] example in Getting Started/Next Steps to be backwards:
# incomplete partial: add(?, 2)
>>> s2 = add.s(2)
# resolves the partial: add(8, 2)
>>> res = s2.delay(8)
>>> res.get()
10
Shouldn't it behave like functools.partial[2]?
>>> import functools
>>> abc = lambda a, b, c: (a, b, c)
>>> bc = functools.partial(abc, "a")
>>> bc("b", "c")
('a', 'b', 'c')
1. http://docs.celeryproject.org/en/latest/getting-started/next-steps.html#and-there-s-that-calling-api-again http://docs.celeryproject.org/en/latest/getting-started/next...
2. http://docs.python.org/library/functools.html#functools.partial http://docs.python.org/library/functools.html#functools.part...
- asksol 14y agoVery good question! The reason is that I found that it better matches what you use them for in Celery, since they are used e.g. to forward results from the previous tasks to a callback. Often you have a signatures like: def blur_image(image, amount=1), where the partial is used like render_image.s(file) | blur_image.s() functools.partial is usually used the other way; it's most common to create functools.partials where the first argument is satisfied.