C API PyObject_CallFunctionObjArgs returns incorrect result

Jen Kris jenkris at tutanota.com
Mon Mar 7 12:13:22 EST 2022


The PyObject str_sentence is a string representation of a list.  I need to convert the list to a string like "".join because that's what the library call takes.  


Mar 7, 2022, 09:09 by rosuav at gmail.com:

> On Tue, 8 Mar 2022 at 04:06, Jen Kris via Python-list
> <python-list at python.org> wrote:
>
>> But with the C API it looks like this:
>>
>> PyObject *pSentence = PySequence_GetItem(pSents, sent_count);
>> PyObject* str_sentence = PyObject_Str(pSentence);  // Convert to string
>>
>> PyObject* repr_str = PyObject_Repr(str_sentence);
>>
>
> You convert it to a string, then take the representation of that. Is
> that what you intended?
>
> ChrisA
> -- 
> https://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list