Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacement for PyString_AS_STRING in python 3.x

Tags:

python

In python 2.x versions there is a function named as PyString_AS_STRING to convert a pyobject pointer to a string or char pointer.

How can we achieve the same functionality in python 3?

like image 729
distribute Avatar asked Nov 06 '22 12:11

distribute


1 Answers

There's a PyUnicode_AS_UNICODE macro.

BTW: PyString_AS_STRING only works for string objects, returning a C string.

like image 82
Ned Batchelder Avatar answered Nov 12 '22 16:11

Ned Batchelder