I think the problem is with the python evaluation set-up code. It throws the syntax error as it needs a valid python syntax and "?" is IPython command line specific. I found a couple of functions that would send a string directly to the interpreter:
comint-redirect-send-command
and comint-redirect-send-command-to-process
.
These do the job pretty well.
Edit:
I've just come across the following. One can run IPython specific commands from script (or as a send string) using the following command.
get_ipython().run_line_magic('pinfo2', 'list''object')
This is equivalent to running listobject??
in the IPython console. pinfo
is equivalent to listobject?
.