Extention Module/ list of chars-> string

Fredrik Lundh fredrik at pythonware.com
Wed Oct 19 16:09:16 EDT 2005


"Tuvas" wrote:

> I am currently writing an extention module that needs to recieve a list
> of characters that might vary in size from 0 to 8. This is written as a
> list of characters rather than a string because it's easier to
> manipulate. However, when I pass this list of characters into the
> extention module, it keeps giving errors. Is there a way to do one of
> the following?
>
> A. Change a list of chars to a single string or

that's easier to do at the python side of things (see martin's reply), but
if you'd rather do

> B. Read a list of chars in an extention module

you might find the code on this page somewhat useful:

    http://effbot.org/zone/python-capi-sequences.htm

(use PyString_Check, PyString_Size and PyString_AsString to process
the sequence items. see the C API reference for details)

</F>






More information about the Python-list mailing list