Thanks this is helpful. -----Original Message----- From: Gabriel Genellina [mailto:[EMAIL PROTECTED] Sent: 15 November 2007 12:26 To: python-list@python.org Subject: Re: How to evaluate the code object returned by PyParser_SimplePa rseString function?
En Wed, 14 Nov 2007 23:20:14 -0300, Borse, Ganesh <[EMAIL PROTECTED]> escribió: > Py_CompileString takes the source code from file, isn't it? > As can be seen from the syntax of this function: PyObject* > Py_CompileString(char *str, char *filename, int start) > > I want to parse the code which is in memory - loaded from database. > In that case, may I know, how to use the Py_CompileString? The first argument is the actual source code string, a char*; the filename argument is only used to generate pretty error messages, you may pass in some meaningful name or '<string>'. > If it is mandatory to read from file for this function? > Reading from file increases startup time of my application. > So, I was thinking of using PyParser_SimpleParseString, which takes > the code to be parsed in the "char*" format. Quit suitable to my need. No, both Py_CompileString and PyParser_SimpleParseString take the same first argument, a char* with the source code. > Can I use the output of the function PyParser_SimpleParseString as > input to PyEval_EvalCode? Not directly, you must compile the parsed input first. See pythonrun.c for examples, but you will end duplicating what Py_CompileString already does. -- Gabriel Genellina ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== -- http://mail.python.org/mailman/listinfo/python-list