[Python-ideas] Rehabilating reduce (as "fold")

Zachary Ware zachary.ware+pyideas at gmail.com
Fri Jul 12 22:53:40 CEST 2013


On Fri, Jul 12, 2013 at 2:53 PM, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
>
> On Fri, Jul 12, 2013 at 10:54 AM, Barry Warsaw <barry at python.org> wrote:
>>
>> >(Independent of this idea, it would actually be nice if the operator
>> > module
>> >had a dictionary mapping from op symbols to names, like
>> >operator.by_symbol["+="] giving operator.iadd)
>>
>> ...but this is a neat idea.
>
>
> -1
>
> This is neat, but I don't really see much use beyond implementing things
> like  fold("+=", ..) that you've just rejected.

I do somewhat agree that there may not be much place to use this in
the standard library, but I think it could make use of the operator
module a bit easier to read in some cases.  For instance, it takes me
a second thought to correctly parse `operator.irshift` as "right-shift
in-place" instead of "IR shift" (which may or may not mean anything,
but certainly doesn't in Python).  On the other hand,
`operator.get_op(">>=")` shows what the returned function is going to
do.


--
Zach


More information about the Python-ideas mailing list