[issue5567] Operators in operator module don't work with keyword arguments
Raymond Hettinger
report at bugs.python.org
Thu Mar 26 18:27:44 CET 2009
Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:
Sounds like what you're really looking for is a version of partial()
that lets you bind positional arguments in any position. Something
like: partial(operator.mod, (1,2)) that pre-binds 2 to argument
position 1.
Changing the language to match the existing partial() function instead
of changing partial() to fit the language seems like "the tail wagging
the dog".
FWIW, I don't think partial actually buys you anything useful. It's
implementation isn't as flexible as a lambda, nor is it any faster. I
think it mainly serves those who have an aversion to lambda, perhaps
because of its name.
Also, I don't think it's a good idea to assign arbitrary keywords to the
operator functions unless those keywords have some meaning that makes
programs more readable. The names "a" and "b" are only mildly useful a
position placeholders. Names like "divisor" and "dividend" are more
descriptive, but that is overkill.
Overall, am -1 on the proposal.
----------
assignee: -> rhettinger
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5567>
_______________________________________
More information about the Python-bugs-list
mailing list