Why doesn't PyRun_String evaluate bool literals?

If you want True and False they will have to be in the globals dict passed to the interpreter. You might be able to fix that by calling PyEval_GetBuiltins.

PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals); If you want True and False they will have to be in the *globals dict passed to the interpreter. You might be able to fix that by calling PyEval_GetBuiltins. From the Python 2.6 source code: if (PyDict_GetItemString(globals, "__builtins__") == NULL) { if (PyDict_SetItemString(globals, "__builtins__", PyEval_GetBuiltins())!

= 0) return NULL; } If that doesn't work, you could try to PyRun_String("import __builtin__ as __builtins__", globals, locals) before calling PyRun_String("True", ...). You might notice the Python interactive interpreter always runs code in the __main__ module which we haven't bothered to create here. I don't know whether you need to have a __main__ module, except that there are a lot of scripts that contain if __name__ == "__main__".

Didn't know this, good answer! – Torsten Marek Feb 4 '09 at 19:36 wow, I never realized that True, False and even None are part of the builtin module... the first solution did it for me, thank you for pointing me in the right direction! I found some more info here: python.Org/doc/2.3/whatsnew/section-bool.

Html – UncleZeiv Feb 4 '09 at 23:06.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions