# HG changeset patch # User catherine@Elli.myhome.westell.com # Date 1237415249 14400 # Node ID 8c277a37e2bc6000118d21430950dbf7e8c9e1a4 # Parent 35be1f8332a95d8904fe56aec3170e02719674af yay py works fully diff -r 35be1f8332a9 -r 8c277a37e2bc cmd2.py --- a/cmd2.py Wed Mar 18 15:32:08 2009 -0400 +++ b/cmd2.py Wed Mar 18 18:27:29 2009 -0400 @@ -742,7 +742,10 @@ os.system(arg) def do_py(self, arg): - '''Executes a python command''' + ''' + py : Executes a Python command. + py: Enters interactive Python mode (end with `\py`). + ''' if arg.strip(): try: result = eval(arg, self.pystate) @@ -758,11 +761,11 @@ while not buffer[-1].strip().startswith('\\py'): try: buf = '\n'.join(buffer) - result = eval(buf, self.pystate) - if result is None: + try: + result = eval(buf, self.pystate) + print repr(result) + except SyntaxError: exec(buf, self.pystate) - else: - print result buffer = [self.pseudo_raw_input('>>> ')] except SyntaxError: buffer.append(self.pseudo_raw_input('... '))