HOWTO : Py_CompileString !?!?!

Werner Schiendl n17999924.temp.werner at
Thu Jan 30 19:15:31 CET 2003

On Thu, 30 Jan 2003 09:54:56 -0500, Luc <acid_til at> wrote:


your script does not contain a syntax error.
You are calling a non-existent method, but this would not be detected until 

So the code compiles well and will cause a runtime error (probably 
NameError excpetion).

If you want try your code for handling syntax errors in scripts, you can 
for example omit the parentheses for the function definition (or add a 
second pair like so: def test()():

This should return an error at compile time.

best regards

-- snip --

> Here is the script in question :
> import FOMath
> #FOMath has a method called PointValue()
> def test():
> 	print FOMath.PointdddValue()
> test()
> This should't compile because a syntax error is present...
> The way I compile the code from C++ is done like so :
> //str contains the file that just loaded...
> Py_CompileString((char*)str.c_str(), "<>", Py_file_input);
> That's it. It's the way I tought was proper. Might be wrong, that's why I 
> posted in this group :)
> Cheers, Luc.

More information about the Python-list mailing list