Need Help Differentiating Bad Commands From Incomplete Commands

Tim Stanka timstanka at bluefrog.com
Fri Jul 30 08:54:59 EDT 2004


Thanks in advance for any responses.

I have an application which embeds Python. I also have a command window
for using Python interactively. The last piece I have left is to
detect incomplete (ie "for x in range(10):") vs bad ("fer x in ronge(10):")
input. Basically I read a line of input from my command window and
feed it to PyRun_SimpleString(command). This command returns 0 on a 
good, complete command ("a = 10") but returns non-zero on bad and incomplete
commands. I need to do something else to differentiate between the last two.

I did find a section in the FAQ docs which gave some sample code:
       n = PyParser_ParseString(m_python_command,  
                        &_PyParser_Grammar,Py_file_input, &e);
Problem is _PyParser_Grammar gives me an "unresolved external" error.
I did some searching through the .h files and the actual source code and
I could not find this symbol. I did some searching on the web and found
a little snippit that indicated it was an extern which used to be defined
in a .c file. 

The C-API manual doesn't list PyParser_ParseString() as a function. I'm 
thinking it might have been a wrapper for another function.

Does anyone have a code snippit I could use for my purpose?

Thanks,
Tim



More information about the Python-list mailing list