C API for str methods?
Martin v. Loewis
martin at v.loewis.de
Fri Aug 2 04:09:57 EDT 2002
More information about the Python-list mailing list
Fri Aug 2 04:09:57 EDT 2002
- Previous message (by thread): Tkinter canvas colors win32
- Next message (by thread): C API for str methods?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Bjorn Pettersen" <BPettersen at NAREX.com> writes: > Is there a reason why methods like str.split, str.join are not > accessible through a C API? (PyUnicode seems to have a lot more of the > functionality available through a C API although not all of them...) In general, everything you can do in Python is accessible through the C API. > # change last expression, e, to "magicVar = e" > lines = block.split('\n'); That will be lines = PyObject_CallMethod(block, "split", "s", "\n"); > stmts = '\n'.join(lines[:-1]) That is PyObject_DelItem(lines, PyList_Size(lines) - 1); nl = PyString_FromStringAndSize("\n", 1); stmts = PyObject_CallMethod(nl, "join", "O", lines); etc. HTH, Martin
- Previous message (by thread): Tkinter canvas colors win32
- Next message (by thread): C API for str methods?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list