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

Chris Angelico rosuav at gmail.com
Fri Mar 21 03:49:12 CET 2014


On Fri, Mar 21, 2014 at 12:28 PM, Brandon W Maister <bwmaister at gmail.com> wrote:
> We could, hypothetically, create an "operators" dict (or dicts) alongside
> locals and globals. Then, if an unexpected token shows up in operator
> position (which is probably well-defined?) before a SyntaxError is raised
> the token is looked up in the operators dict.

The SyntaxError is raised at compilation time; locals and globals are
at run time. The only way that would work is if you do something like
this:

operators["b"] = lambda left, right: whatever
import module_using_b

ChrisA


More information about the Python-ideas mailing list