Equivalent Python API Code

winkjj at my-deja.com winkjj at my-deja.com
Wed Dec 1 16:45:28 EST 1999


Could someone show me how to implement the following Python code using
the C API?

>>> mystr = '[100,200,300]'
>>> mylist = eval(mystr)
>>> mylist
[100, 200, 300]

Basically, I want to take a char* that holds the value of mystr, and
eval it, obtaining a PyObject* to a list.

Generically, I want to be able to eval any char* that represents some
code, and obtain a PyObject* to the real object...

I've tried using PyRun_String with the start token set to
Py_eval_input, but this doesn't work correctly.

Thanks in advance for your help....

Jeff.


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list