How do I convert a PyObject to string in C++?

Aaron "Castironpi" Brady castironpi at gmail.com
Mon Sep 22 22:54:17 EDT 2008


On Sep 22, 9:32 pm, lixinyi... at gmail.com wrote:
> I have a PyObject, say 'Hello World' , a string,
> How do I convert it to a string in C++?
> Thanks in advance!

Look at PyString_AsStringAndSize .  It gives you a pointer to a buffer
and a size.  Allocate a new one and copy it if you need to modify it,
or you want a copy that outlives the object version.



More information about the Python-list mailing list