ITeye博客

2015 年文章归档

共 2 篇文章

lost on Py_DECREF/INCREF when handling PyList_Append in Python C extension

The main hint is in the docs, if it says 'Steals a reference' than the function basically takes ownership, if it says 'New Reference' than it did an INCREF for you, if nothing is said it probably does an INCREF and DECREF pair as needed. http://stackoverflow.com/questions/10863669/lost-on-py-decref…

2015-11-03 21:41 · c++ · python · c

How can I convert a character to a integer in Python, and viceversa?

Use chr() and ord(): chr(97) 'a' ord('a') 97

2015-10-27 14:38 · python