Parse Mathematica code to Python

154 views
Skip to first unread message

Arihant Parsoya

unread,
Apr 11, 2017, 4:03:27 AM4/11/17
to mathics-devel
Hi,

I came to know that mathics has good Mathematica to Python parser. I wanted to know how I can use it to convert my Mathematica code to Python(an example would be nice)?


Thanks,
Arihant

Angus Griffith

unread,
Apr 13, 2017, 1:35:11 AM4/13/17
to mathic...@googlegroups.com
Hi Arihant,

Mathics is a Mathematica interpreter written in Python.

Mathics has a Mathematica parser but we don't have a way to emit python code from the AST.

You can construct a python representation of the Mathematica code, and even covert the algebraic expressions to Sympy objects (which I believe has some code emitting functionality) but Mathics itself doesn't output python code.

Does that make sense?
Angus 

--
You received this message because you are subscribed to the Google Groups "mathics-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathics-devel+unsubscribe@googlegroups.com.
To post to this group, send email to mathic...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathics-devel/be0c87dd-87f7-4799-9333-db0f74670e60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Arihant Parsoya

unread,
Apr 18, 2017, 9:56:10 AM4/18/17
to mathics-devel
Yes, thanks.


On Thursday, April 13, 2017 at 11:05:11 AM UTC+5:30, Angus wrote:
Hi Arihant,

Mathics is a Mathematica interpreter written in Python.

Mathics has a Mathematica parser but we don't have a way to emit python code from the AST.

You can construct a python representation of the Mathematica code, and even covert the algebraic expressions to Sympy objects (which I believe has some code emitting functionality) but Mathics itself doesn't output python code.

Does that make sense?
Angus 

On 11 Apr. 2017 01:03, "Arihant Parsoya" <parsoya...@gmail.com> wrote:
Hi,

I came to know that mathics has good Mathematica to Python parser. I wanted to know how I can use it to convert my Mathematica code to Python(an example would be nice)?


Thanks,
Arihant

--
You received this message because you are subscribed to the Google Groups "mathics-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathics-deve...@googlegroups.com.

Rocky Bernstein

unread,
Sep 5, 2020, 2:19:04 PM9/5/20
to mathics-devel
I have extended Robert Jacobsen's FoxySheep parser so that it can emit Python; it does by first going to a Python AST and then astor turns that into a Python string. 
There is also a simple REPL , and there are options to tailor the output to be suitable with for numpy, scipy, sympy, or plain Python. 

See FoxySheep or pip install FoxySheep. What's there now is pretty minimal but I think the foundation is pretty good. 

I did this before learning about mathics. So there's an obvious question of how hard would it be to hook the two together? 
 
On Thursday, April 13, 2017 at 1:35:11 AM UTC-4 Angus wrote:
Hi Arihant,

Mathics is a Mathematica interpreter written in Python.

Mathics has a Mathematica parser but we don't have a way to emit python code from the AST.

You can construct a python representation of the Mathematica code, and even covert the algebraic expressions to Sympy objects (which I believe has some code emitting functionality) but Mathics itself doesn't output python code.

Does that make sense?
Angus 

On 11 Apr. 2017 01:03, "Arihant Parsoya" <parsoya...@gmail.com> wrote:
Hi,

I came to know that mathics has good Mathematica to Python parser. I wanted to know how I can use it to convert my Mathematica code to Python(an example would be nice)?


Thanks,
Arihant

--
You received this message because you are subscribed to the Google Groups "mathics-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathics-deve...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages