restoring the default completer in IPython

Michele Simionato michele.simionato at gmail.com
Tue Aug 21 09:35:58 EDT 2007


This should probably go to the IPython list, but since I am not
subscribed I will try my luck here.
Basically, I want to embed IPython inside a command line interpreter
based on cmd.Cmd, in this
way:

import cmd, IPython

class Cmd(cmd.Cmd):
    def do_ipython(self, arg):
        ipython = IPython.Shell.IPShellEmbed()
        ipython(global_ns=globals())
    def do_EOF(self, arg):
        return 1

Cmd().cmdloop()

It works, however when I exit from the IPython shell (after giving the
ipython command) the Cmd
class is still using the IPython readline completer, not the original
one. By looking at the source
code of IPShellEmbed I see that there is a
method .restore_system_completer() which is
called, but it seems to be not working. I am probably doing something
wrong, can somebody knowledgeable on IPython internals share some
light on that? TIA,

      Michele Simionato




More information about the Python-list mailing list