changeset 236:035330ccfcf0

py really working right now
author catherine@dellzilla
date Tue, 24 Mar 2009 13:59:00 -0400
parents 78ad20c2eed0
children e91808980e59
files cmd2.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Tue Mar 24 13:48:25 2009 -0400
+++ b/cmd2.py	Tue Mar 24 13:59:00 2009 -0400
@@ -792,8 +792,7 @@
     def do_py(self, arg):  
         '''
         py <command>: Executes a Python command.
-        py: Enters interactive Python mode; end with `Ctrl-D`.
-            Do not end with Ctrl-Z, or it will end your entire cmd2 session!
+        py: Enters interactive Python mode; end with `Ctrl-D`, `quit()`, or 'exit`.
         Non-python commands can be issued with cmd('your non-python command here').
         '''
         if arg.strip():
@@ -803,9 +802,11 @@
             interp = MyInteractiveConsole(locals=self.pystate)
             def quit():
                 raise EmbeddedConsoleExit
+            def onecmd(arg):
+                return self.onecmd(arg + '\n')
             self.pystate['quit'] = quit
             self.pystate['exit'] = quit
-            self.pystate[self.nonpythoncommand] = self.onecmd
+            self.pystate[self.nonpythoncommand] = onecmd
             try:
                 interp.interact()
             except SystemExit: