I understand that it would be possible to do something like
i = numpy.array([1,0,0]) j = numpy.array([0,1,0]) k = numpy.array([0,0,1]) a = 2*i + 5*j + 9*k
but is it possible to use a similar syntax for how complex numbers are executed, and create a class that can define 2i + 5j + 9k , is a member of my class and automatically creates it?
Or would you need to change the python interpreter by changing the way files are handled? I looked at the grammar file, but all I see is NUMBER , and j not mentioned once.
I also looked at parsermodule.c , but could not easily notice something there, which made it obvious how to do this.
Does anyone know how this is possible?
I probably should add that I really do not plan to do this (if by some miracle it turned out that it was not necessary to recompile my own version of python, which would be crazy to do anything other than an academic trip) but just from curiosity about how the language works.
source share