From Girish.Goudar at goodrich.com Mon Mar 1 09:35:47 2010 From: Girish.Goudar at goodrich.com (Goudar, Girish) Date: Mon, 1 Mar 2010 16:35:47 +0800 Subject: [capi-sig] (no subject) In-Reply-To: <87iq9j3os7.fsf@busola.homelinux.net> Message-ID: Hi This is working file. Thanks. -----Original Message----- From: Hrvoje Niksic [mailto:hniksic at xemacs.org] Sent: Friday, February 26, 2010 10:42 PM To: Goudar, Girish Cc: capi-sig at python.org Subject: Re: [capi-sig] (no subject) "Goudar, Girish" writes: > Thanks for the quick reply. I can use the struct module at Python side > and use the pack() function to pack the data. But in the DEOS side I > need to unpack the data for that I need to use unpack() function. But > DEOS is not supporting unpack() function. What to do? I meant to use that you can use struct.pack to create data that can be interpreted as a structure defined in C, assuming the same architecture is run on both machines. Such sharing of data is one of the use cases of the struct module. For example: # python side: import struct s = struct.pack('cid', 'A', 10, 20.0) send_data_to_network(s) /* C side: */ struct data_desc { char c; int i; double d; }; char *s; struct data_desc data; s = read_data_from_network(); memcpy(&data, s, sizeof(data)); /* data.c is now the char data.i the int data.d the float (double) */ From dr.cg at 126.com Tue Mar 9 07:18:17 2010 From: dr.cg at 126.com (CHEN Guang) Date: Tue, 9 Mar 2010 14:18:17 +0800 (CST) Subject: [capi-sig] The C language for Python programmers --- PythoidC Message-ID: <15f67e1.4b3d.1274192e137.Coremail.dr.cg@126.com> Hi, if you want to write and run C code in Python IDE with auto-completion if you want to introspect into C functions and data structs if you hate the {} and ; and the DOS window (console) Please take a look at: http://pythoidc.googlecode.com PythoidC is the C language like the Python, by the Python and for the Python import c c.include(c.h.stdio) c.include(c.h.stdlib) '''Annotation is free!''' int fib(int n): if(n<=2): return1 else: return fib(n-1)+ fib(n-2) int main(int argc,char**argv): int n //C style annotation n=c.stdlib.atoi(argv[1]) c.stdio.printf('fibonacci(%d)=%d\n', n, fib(n))