Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grabbing the output of MAPLE via Python

How would I use the subprocess module in Python to start a command line instance of MAPLE to feed and return output to the main code? For example I'd like:

X = '1+1;'
print MAPLE(X)

To return the value of "2".

The best I've seen is a SAGE wrapper around the MAPLE commands, but I'd like to not install and use the overhead of SAGE for my purposes.

like image 488
Hooked Avatar asked Dec 02 '25 03:12

Hooked


1 Answers

Trying to drive a subprocess "interactively" more often than not runs into issues with the subprocess doing some buffering, which blocks things.

That's why for such purposes I suggest instead using pexpect (everywhere but Windows: wexpect on Windows), which is designed exactly for this purpose -- letting your program simulate (from the subprocess's viewpoint) a human user typing input/commands and looking at results at a terminal/console.

like image 123
Alex Martelli Avatar answered Dec 04 '25 15:12

Alex Martelli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!