multi-line input?

joshusdog at gmail.com joshusdog at gmail.com
Mon May 14 17:50:35 EDT 2007


I'm writing a C++ application with an embedded Python interpreter.
Command text is captured and passed to the interpreter a single line
at a time. My question is this: is there a simple way of determining
whether a given input line of text will cause the prompt to change
from the regular ">>>" to the multi-line "..." before sending the text
to the interpreter? I suppose the completely correct solution would be
tokenize and parse the entire string and then examine all the
constituent parts, but that seems like a lot more work than I really
want to do.

As far as I can tell, there are only a few ways to trigger the multi-
line input prompt:

- if-statement, for-loop, function or class definition
- line continuation (\)
- block quote (""" or ''')

Any help would be greatly appreciated.




More information about the Python-list mailing list