pytoolz / toolz

A functional standard library for Python.
http://toolz.readthedocs.org/
Other
4.57k stars 258 forks source link

Improve flip to accept *args and kwargs #566

Open brl0 opened 1 year ago

brl0 commented 1 year ago

First, thanks for the great project!

Currently, flip is limited to two arguments, and it does not handle keyword arguments. I might be missing something, but this seems easy to fix, and should be a non-breaking change.

Let me know if any other changes are needed.

groutr commented 11 months ago

@brl0 I agree that flip is limited to two arguments and that generalizing is desirable, especially with keyword arguments. When there are two arguments, there is only one possible variation (a, b) -> (b, a). When there are more than two arguments, flip becomes ambiguous because more variations are possible. How often is it desirable to reverse the order of all of the positional arguments? Do you have a use case that this PR solves?

Would the approach in #546 work for your use case?