how to match a regulas expresion like (%i1) in python pexpect
Posted
by
mike
on Stack Overflow
See other posts from Stack Overflow
or by mike
Published on 2012-12-15T10:59:49Z
Indexed on
2012/12/15
11:03 UTC
Read the original article
Hit count: 359
I want to use maxima from python using pexpect, whenever maxima starts it will print a bunch of stuff of this form:
$ maxima
Maxima 5.27.0 http://maxima.sourceforge.net
using Lisp SBCL 1.0.57-1.fc17
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1)
i would like to start up pexpect like so:
import pexpect
cmd = 'maxima'
child = pexpect.spawn(cmd)
child.expect (' match all that stuff up to and including (%i1)')
child.sendline ('integrate(sin(x),x)')
chil.expect( match (%o1 ) )
print child.before
how do i match the starting banner up to the prompt (%i1)? and so on, also maxima increments the (%i1)'s by one as the session goes along, so the next expect would be:
child.expect ('match (%i2)')
child.sendline ('integrate(sin(x),x)')
chil.expect( match (%o2 ) )
print child.before
how do i match the (incrementing) integers?
© Stack Overflow or respective owner