Multiline command line parsing

Brad Johnson Brad.Johnson at ballardtech.com
Tue Sep 18 20:17:09 EDT 2007


I am implementing a Python command line from scratch in a Win32 application.

Examples online ("How do I tell incomplete input from invalid input" in the
Extending and Embedding Python FAQ) show how to implement this from scratch
using C code. The examples don't work.

This brief snippit illustrates the problem:

char* code = "class Foo:\n"
		"\tdef Bar():\n";
PyObject* temp = PyRun_String(code, Py_single_input, glb, loc);

The syntax is completely valid, but should return an "unexpected EOF while
parsing" (which I can handle). However, I receive "expected an indented block."

Shouldn't this example work as stated? Is there something I am missing about my
indentation technique, or any specific Win32 issues lurking?




More information about the Python-list mailing list