Extention Module/ list of chars-> string

Discussion in 'Python' started by Tuvas, Oct 19, 2005.

  1. Tuvas

    Tuvas Guest

    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!
     
    Tuvas, Oct 19, 2005
    #1
    1. Advertising

  2. 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
     
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=, Oct 19, 2005
    #2
    1. Advertising

  3. "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>
     
    Fredrik Lundh, Oct 19, 2005
    #3
  4. Tuvas

    Tuvas Guest

    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!
     
    Tuvas, Oct 20, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carl Ogawa

    How do I make .cgi extention work?

    Carl Ogawa, Dec 27, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,025
  2. Tuvas

    Extention String returning

    Tuvas, Oct 24, 2005, in forum: Python
    Replies:
    3
    Views:
    293
    Tuvas
    Oct 24, 2005
  3. Kosio

    Floats to chars and chars to floats

    Kosio, Sep 16, 2005, in forum: C Programming
    Replies:
    44
    Views:
    1,327
    Tim Rentsch
    Sep 23, 2005
  4. Hongyu
    Replies:
    9
    Views:
    949
    James Kanze
    Aug 8, 2008
  5. M.Posseth

    receiving ??? chars instead of "special" chars

    M.Posseth, Nov 15, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    268
    Dan Rogers
    Nov 16, 2004
Loading...

Share This Page