Comment #1 on issue 2594 by matt...@gmail.com: Better handling of
multi-line statements at SymPy Live
http://code.google.com/p/sympy/issues/detail?id=2594
Python/IPython can take advantage of `code.compile_command()`, which works
almost exactly as built-in `compile()`, but returns None if the input is
valid but incomplete Python code, e.g.:
In [1]: import code
In [2]: code.compile_command('if x:', '<string>', 'exec')
In [3]: code.compile_command('if x::', '<string>', 'exec')
------------------------------------------------------------
File "<string>", line 1
if x::
^
SyntaxError: invalid syntax
Note that this also works in cases where there is no `:`, e.g.:
In [4]: code.compile_command('[1,2,3,', '<string>', 'exec')
What we can do is to make Enter the default for evaluation and Shift+Enter
for newlines, and when user enters an incomplete statement and presses
Enter, send the input to GAE anyway, use code module to recognize that this
is valid partial input, return to the client side "partial-input" message
and move the cursor the next line. To optimize speed, we can check if
cursor-1 is ':' and if so, skip the round trip and move the cursor to the
new line immediately.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.