msg192970 - (view) |
Author: Zachary Ware (zach.ware) *  |
Date: 2013-07-12 20:46 |
In a thread on python-ideas[1], Nick mentioned the idea of ``operator.by_symbol['+=']`` which would be an alternative method of getting the operator.iadd function. The idea struck my fancy, so I implemented it (regardless of the very real possibility of being rejected anyway, judging by the current split vote in the thread :)). I also implemented Brett's suggestion of supporting '.attribute' and '[item]' as well. Here's the (still a bit rough) patch. [1] http://mail.python.org/pipermail/python-ideas/2013-July/022078.html |
|
|
msg192973 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2013-07-12 21:41 |
Added some comments on Rietveld. |
|
|
msg193058 - (view) |
Author: Ron Adam (ron_adam) * |
Date: 2013-07-14 15:48 |
Regarding opertor.get_op: Look at help("symbols") output for consistancy. There may be items in one that can be included in the other. The operator.get_op addition would be useful for improving help on the symbol information for help/pydoc. Currently it seems overly general for symbols. Also patch, http://bugs.python.org/issue18387, which adds help("symbols") output to pydocs web browser interface. It could use a review. |
|
|
msg193080 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2013-07-15 07:57 |
What is a purpose of this feature? Why you need it? |
|
|
msg193106 - (view) |
Author: Zachary Ware (zach.ware) *  |
Date: 2013-07-15 14:30 |
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. |
|
|
msg193107 - (view) |
Author: Alyssa Coghlan (ncoghlan) *  |
Date: 2013-07-15 14:37 |
I liked Ron's suggestion of using it to improve the output of help() (by getting access to the docstrings of the operator functions, and then enhancing those to be a bit more informative) |
|
|
msg223957 - (view) |
Author: Zachary Ware (zach.ware) *  |
Date: 2014-07-25 15:15 |
With no one (including me) clamoring for this, I'm going to go ahead and reject it. If someone in the future does really want this, I'd be happy to review a new patch. |
|
|