starting repl programmatically
Patrick Maupin
pmaupin at gmail.com
Thu May 20 20:35:06 EDT 2010
On May 20, 6:57 pm, Brendan Miller <catph... at catphive.net> wrote:
> I have a python script that sets up some environmental stuff. I would
> then like to be able to change back to interactive mode and use that
> environment. What's the best way to do that?
>>> import cmd
>>> class MyCmd(cmd.Cmd):
... def default(self, line):
... exec line in globals()
...
>>> MyCmd().cmdloop()
(Cmd) s = 'The answer is probably to use %s'
(Cmd) print s % 'the cmd module'
The answer is probably to use the cmd module
(Cmd)
Regards,
Pat
More information about the Python-list
mailing list