PyImport_ImportModule("cStringIO") failure with undefined symbol

2008-01-10 Thread Borse, Ganesh
Hi, Can you please guide me for the following problem? The call to "PyImport_ImportModule("cStringIO");" is failing with an error of "undefined symbol: PyObject_SelfIter". Before importing this module, I am importing only the sys module. Py_SetProgramName("/usr/bin/python"); Py_Initialize(

Question on compiled code when embedding Python in C++

2007-12-03 Thread Borse, Ganesh
When we compile a Python code using functions such as Py_CompileString or any other similar compile function, what will be the resulting executable code? Will it be byte code somewhat like the byte code of Java? Or it will be the same binary code like the once generated by C/C++ compilers from th

RE: Please help in creating Python function in C ++ program

2007-11-22 Thread Borse, Ganesh
--Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 22 November 2007 15:07 To: Borse, Ganesh Cc: python-list@python.org Subject: Please help in creating Python function in C ++ program Forwarded to python-list@python.org --- "Borse, Ganesh" <[EMAIL PROTECTED]>

Compiling python functions on the fly & calling from C++

2007-11-20 Thread Borse, Ganesh
I want to call Python function which takes input arguments (parameters) from C++ program on the fly when program is running, as below: def isSizeSmall(size,vol,ADV,prod): if ( (size < 1000) & (vol < (0.001 * ADV)) & (prod=="Stock")): return 100 else: return 11 I tried following approach

RE: PyObject_GetAttrString failing when getting a function pointe r fr om PyObject* returned by Py_CompileString

2007-11-20 Thread Borse, Ganesh
> Can we not use the "PyObject*" returned by Py_CompileString as input to > PyObject_GetAttrString? > What could be wrong? >>>per documentation >>>compile string returns None when you use Py_file_input This is not true. I am getting a valid code object returned when I am using "" & Py_file_input.

PyObject_GetAttrString failing when getting a function pointer fr om PyObject* returned by Py_CompileString

2007-11-20 Thread Borse, Ganesh
Hi, My following code is failing with an error of "isSizeSmall not function or callable" //--- char szExpr[2048]; memset(szExpr,'\0',sizeof(szExpr)); sprintf(szExpr,"def isSizeSmall(size,vol,ADV,prod):\n if ( (size < 1000) & (vol < (0.001 * ADV))

How to access C variables in Python code object generated by Py_C ompileString

2007-11-20 Thread Borse, Ganesh
Hi, May you please help in using Py_CompileString & PyEval_EvalCode to parse+compile an expression at startup & evaluate that multiple times at runtime. I want to use this in C++ program as below. Here, the expression contains the variables like size, vol, ADV, etc. The values of these variable

RE: How to evaluate the code object returned by PyParser_SimplePa rseString function?

2007-11-16 Thread Borse, Ganesh
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

Re: evaluating object returned by PyParser_SimpleParseString fun ction

2007-11-15 Thread Borse, Ganesh
Thanks for this. >>Terry>>Compile the string into a code object. Code objects can be executed by >>an exec statement or evaluated by a call to eval(). Can I call exec() or eval() as is from C or C++ program? What the equivalent calls for this in Python-C API? That's what I want to know. Regards

What is the function to evaluate code object returned by PyParser _SimpleParseString function?

2007-11-15 Thread Borse, Ganesh
er 2007 07:51 To: python-list@python.org Subject: Re: How to use the evaluate the code object returned by PyParser_Simp leParseString function? En Wed, 14 Nov 2007 06:48:41 -0300, Borse, Ganesh <[EMAIL PROTECTED]> escribió: > `struct _node* PyParser_SimpleParseString(char *str, int start)

RE: How to evaluate the code object returned by PyParser_SimplePa rseString function?

2007-11-14 Thread Borse, Ganesh
ROTECTED] Sent: 15 November 2007 07:51 To: python-list@python.org Subject: Re: How to use the evaluate the code object returned by PyParser_Simp leParseString function? En Wed, 14 Nov 2007 06:48:41 -0300, Borse, Ganesh <[EMAIL PROTECTED]> escribió: > `struct _node* PyParser_SimplePars

How to use the evaluate the code object returned by PyParser_Simp leParseString function?

2007-11-14 Thread Borse, Ganesh
Hi, Can someone please help me in the following question? On the web page http://olympus.het.brown.edu/cgi-bin/info2www?(python2.3-api)Very+High+Level+Layer, I got the following information: `struct _node* PyParser_SimpleParseString(char *str, int start)' Parse Python source code from STR

RE: How to find if a string contains another string

2007-10-29 Thread Borse, Ganesh
erand >>> >>> if smallone in bigstring: ...print 'ok' ... else: ... print 'nok' ... Traceback (most recent call last): File "", line 1, in ? TypeError: 'in ' requires character as left operand Do I need to import any module? Thanks, Ga

How to find if a string contains another string

2007-10-29 Thread Borse, Ganesh
Hi, Am new to python. May someone please help me know this? How can we check whether one big string contains another small string? E.g. bigstring="python anaconda boa cobra" smallone="boa" If 0 == contains(bigstring,smallone): print "Yes, boa is snake.." Is there any function like "co