473,756 Members | 3,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1784
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_AsStri ng 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
8400
by: Dag | last post by:
Is there a python module that includes functions for working with prime numbers? I mainly need A function that returns the Nth prime number and that returns how many prime numbers are less than N, but a prime number tester would also be nice. I'm dealing with numbers in the 10^6-10^8 range so it would have to fairly efficient Dag
2
5029
by: Jesper Olsen | last post by:
I have a python extention implemented in C/C++ - the extention itself is internally implemented in C++, but the interface is pure C, so that it can easily be called from a python C-wrapper. The extention is compiled with distutils, and this has worked well in both Windows and Linux environments. Now, however, I get an
0
1849
by: Atul Kshirsagar | last post by:
I am embedding python in my C++ application. I am using Python *2.3.2* with a C++ extention DLL in multi-threaded environment. I am using SWIG-1.3.19 to generate C++ to Python interface. Now to explain it in details, 1. Python initialization and finalization is done in the *main* thread. 2. For each new thread I create a separate sub-interpreter . 3. Using PyRun_String("import myModule"...) before execution of python
8
3866
by: Bo Peng | last post by:
Dear list, I am writing a Python extension module that needs a way to expose pieces of a big C array to python. Currently, I am using NumPy like the following: PyObject* res = PyArray_FromDimsAndData(1, int*dim, PyArray_DOUBLE, char*buf); Users will get a Numeric Array object and can change its values (and actually change the underlying C array).
1
2601
by: Carl Ogawa | last post by:
How do I make .cgi extention work? I installed ActivePerl 5.8. My CGI scripts work fine with .PL extention but not .CGI extention although I associated CGI extention as exactly same as PL extention in WinXP Prof . Where else should I change to make it work?
1
3080
by: MFA | last post by:
Hi all I have installed Front page server Extention on IIS 5.0 it was working fine. I was able to load project from Visual Interdav and doing well. Yesterday I installed a security update from Microsoft and after that every thing stop working and I am getting the error below when ever I am trying to connect to server using V Interdev. Error Shows that FP Server Extention is not installed but its there even I removed it and installed it...
8
1467
by: Tuvas | last post by:
I am in the process of writing an extention module, and am coming up with lots of problems. Perhaps someone could be of use. I keep getting data that isn't what I'm sending the program. Let me give the line of C code and Python Code and output to illistrate the problem. write_can(can_han,0x0140,'abcd') if (PyArg_ParseTuple(args("iiz#",&can_han,&com,&data,&len) return NULL;
5
2838
by: brokow | last post by:
I was lucky to find Milton L. Hankins' Python 1.5 port of gdbm.pyd on the web a while ago, but I was wondering if there is one that works with a more recent version of Python? (For me, that one kills python24\pythonw.exe in Pythonwin and SPE on import, though it's a VC++ Runtime Error, so it could be a different DLL problem somewhere...) It just seems a little odd that no one would have done this or that it's so tough to find. Of course, I...
5
3138
by: Krustov | last post by:
I have the following list of image files . When searching the latest (numbered file) in this particular case its background_4.*** and its a .jpg file - but - the latest file in the list could also be a .gif file at times . zimages_background/background_1.jpg zimages_background/background_2.jpg zimages_background/background_3.gif zimages_background/background_4.jpg
3
1186
by: Monu | last post by:
Hi All, When I am using shelve on my local machine it generates the db file as given filename. But in another machine it's generating <filename>.dat and .dir. can anyone tell me how can I force sheve module to write the db in <filename>.dir and <filename>.dat, instead of <filename>? Do I have to install a specific version of the python? Thanks... Monu
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.