changeset 221:9aa1f34455b4 0.4.8

autobind test failing
author catherine@Elli.myhome.westell.com
date Wed, 18 Mar 2009 22:02:15 -0400
parents 8c277a37e2bc
children 1d3ad27f2b9e
files cmd2.py
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/cmd2.py	Wed Mar 18 18:27:29 2009 -0400
+++ b/cmd2.py	Wed Mar 18 22:02:15 2009 -0400
@@ -744,21 +744,23 @@
     def do_py(self, arg):  
         '''
         py <command>: Executes a Python command.
-        py: Enters interactive Python mode (end with `\py`).
+        py: Enters interactive Python mode (end with `end py`).
         '''
         if arg.strip():
             try:
                 result = eval(arg, self.pystate)
-                if result is None:
+                print repr(result)
+            except SyntaxError:
+                try:
                     exec(arg, self.pystate)
-                else:
-                    print result
+                except Exception:
+                    raise
             except Exception, e:
                 print e        
         else:
-            print 'Now accepting python commands; end with `\\py`'
+            print 'Now accepting python commands; end with `end py`'
             buffer = [self.pseudo_raw_input('>>> ')]
-            while not buffer[-1].strip().startswith('\\py'):
+            while buffer[-1].lower().split()[:2] != ['end','py']:
                 try:
                     buf = '\n'.join(buffer)
                     try: