0

I am using Python C API to connect to my python v2.7.2

As the title suggests, I am looking to use unicode string as key in my dictionary. I am aware that we can use unicode string as key in python dictionary. But how is that possible through Python C API.

int PyDict_SetItemString(PyObject *p, const char *key, PyObject *val)

we have the above for using the ascii values. Is there any way for it?

Thanks in advance.

D3XT3R
  • 181
  • 2
  • 15
  • I see you have asked 7 questions, but have not marked an accepted answer for any of them. If you ask a question, and someone sufficiently answers your question, then you should click the check-mark outline on the left side of the answer to mark it as "accepted". – Uyghur Lives Matter Feb 09 '15 at 19:34

1 Answers1

1

Use

int PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val)

and pass in a:

PyObject *PyUnicode_FromString(const char *u)

as the key

jamylak
  • 128,818
  • 30
  • 231
  • 230