On Tue, May 18, 2021 at 05:21:28PM +0100, Oscar Benjamin wrote:

> I think that maybe the best solution here is something more like a
> domain-specific language that can be used with ipython/jupyter as an
> alternative profile.

Not just ipython and jupyter. The Python std lib has a module that 
simulates the built-in interpreter. With a bit of jiggery-pokery, it 
should be possible to adapt that to allow a symbolic maths DSL.

https://docs.python.org/3/library/code.html

I think the only limitation is that the code module requires legal 
Python syntax, so you can't write "2x" to get `2*x`. Nevertheless, it 
should be capable of exact fractions.

The sys module has a display hook for customizing printing:

https://docs.python.org/3/library/sys.html#sys.displayhook

It would be nice if it had an input hook as well, so that Martin could 
customise "1/2" to "Fraction(1, 2)". I think that would be a much more 
useful enhancement than ratiofloat.



-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/XZN27W25VI3A5ZROMNJH7SSANSNDZ2XB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to