[Python-ideas] Infix matrix-multiply, but not general infix operators?

Brandon W Maister bwmaister at gmail.com
Thu Mar 20 22:04:25 CET 2014


On Thu, Mar 20, 2014 at 4:14 PM, Ron Adam <ron3200 at gmail.com> wrote:

>    def foo(...):
>      symbol b
>
>      s = 'a' b 'c'
>

Actually makes me think of decorators, which means that you wouldn't even
need new tokens or keywords:

    from functools import make_operator

    bop = make_operator(b)

    s = 'a' bop 'b'

    class Ops:
        @make_operator
        def cat(left, right):
            return left + right

    t = 'a' Ops.cat 'b'

It reduces the grit, but also reduces certain kinds of obviousness.

bwm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140320/800cf2e9/attachment-0001.html>


More information about the Python-ideas mailing list