[issue18436] Add mapping of symbol to function to operator module

Zachary Ware report at bugs.python.org
Mon Jul 15 16:30:45 CEST 2013


Zachary Ware added the comment:

The purpose is to make usage of the operator module more readable, particularly for some of the more exotic operators.  For instance, I find ``operator.get_op(">>=")`` to be a lot more obvious about what's going to happen than ``operator.irshift``.

Also, I think it is helpful to have available a listing of all the operators that Python supports.  If we're going to have such a listing, why not make it a mapping of op to function?  And once we have such a mapping, it would be nice to have a nice interface to it.

Having this available would make it easy to implement the kind of function that Nick mentioned in the python-ideas thread, that takes an operator string instead of only a function.

I will admit that the need is not great, and obviously this isn't something that someone who needs it couldn't do themselves.  But I think the convenience of it makes it at least worth consideration.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18436>
_______________________________________


More information about the Python-bugs-list mailing list