469,356 Members | 2,055 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Extention Module/ list of chars-> string

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
B. Read a list of chars in an extention module

Thanks!

Oct 19 '05 #1
3 1624
Tuvas wrote:
A. Change a list of chars to a single string or
B. Read a list of chars in an extention module


Either is possible, but I recommend to do A:

data = ''.join(data)

Then pass the modified data to the extension module.

Regards,
Martin
Oct 19 '05 #2
"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>

Oct 19 '05 #3
Thanks for the help, I actually ended up writing my own simple
charlist2string function, I realized it was only about 4 lines of code,
but, appreciate the help!

Oct 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

36 posts views Thread by Dag | last post: by
2 posts views Thread by Jesper Olsen | last post: by
1 post views Thread by Carl Ogawa | last post: by
8 posts views Thread by Tuvas | last post: by
5 posts views Thread by Krustov | last post: by
3 posts views Thread by Monu | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.