operator.py 500 B

1234567891011121314151617181920212223
  1. from __future__ import absolute_import
  2. import operator
  3. from toolz.functoolz import curry, num_required_args, has_keywords
  4. def should_curry(f):
  5. num = num_required_args(f)
  6. return num is None or num > 1 or num == 1 and has_keywords(f) is not False
  7. locals().update(
  8. dict((name, curry(f) if should_curry(f) else f)
  9. for name, f in vars(operator).items() if callable(f)),
  10. )
  11. # Clean up the namespace.
  12. del curry
  13. del num_required_args
  14. del has_keywords
  15. del operator
  16. del should_curry