C API -- a second ?
Martin von Loewis
loewis at informatik.hu-berlin.de
Sun Aug 12 07:08:34 EDT 2001
Tavis Rudd <tavis at calrudd.com> writes:
> how does one split a PyString in C? Do I need to use
> PyUnicode_Split() and convert back to plain strings from
> the unicode objects or is there some other way of doing
> this?
You could always call methods on objects:
res = PyObject_CallMethod(mystring, "split", "s", ":");
would be the equivalent of
res = mystring.split(":")
That has some overhead to a direct function call, so you may want to
put a feature request on sf.net/projects/python for exposing the split
function. Note that it is really two functions in the C API, though,
one that takes a string, and one that splits whitespace. When you do
submit a feature request, you may try to propose an interface that can
deal with both cases.
Regards,
Martin
More information about the Python-list
mailing list