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

Steven D'Aprano steve at pearwood.info
Fri Mar 21 01:15:39 CET 2014


On Thu, Mar 20, 2014 at 05:04:25PM -0400, Brandon W Maister wrote:

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

But you would require new syntax. Your suggested syntax 

    s = 'a' bop 'b'

is currently a syntax error.

Keep in mind that any changes to syntax would allow bop to be any 
arbitrary object. Python cannot tell at compile-time whether bop is an 
"operator" or a list or a string or a float, only at run-time.



>     from functools import make_operator
>     bop = make_operator(b)

Do you have any suggestion as to how make_operator would work? What 
should it do? What sort of object is bop?



-- 
Steven


More information about the Python-ideas mailing list