When in the IPython shell, ?open returns help on the "open" function. But when I send it with python-shell-send-string it throws a syntax error saying "?" is not recognised. I can see the output in the IPython shell. I am using Doom Emacs. The default Python shell is set to "python3". I've tried changing it to "ipython3", didn't help.

1 Answer 1


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.


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', 'object')

This is equivalent to running object?? in the IPython console. pinfo is equivalent to object?.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.