On Tue, May 18, 2021, 9:18 PM Steven D'Aprano <st...@pearwood.info> wrote:

> 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


A math DSL that at minimum supported 1. subreddit line these fraction
literals 2. a more math-like lambda syntax, like:

f(x)=x

... 3. a caret symbol for the exponentiation operator would generate quite
a bit of interest from me.

Happily Sage math exists. Sadly, in general I've found it difficult to make
use of Sage compared to regular python. If something like this were
supported as a part of the core language I'd be likely to use it. I have no
idea what kind of effort that would entail on the part of others though.
_______________________________________________
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/KQZZUYMXDIXHTGHQFQSKVLTARYQHTNLB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to