c to python

Jimmy verma jim_938 at hotmail.com
Mon May 26 14:54:49 EDT 2003


Thanks for responding. I dont want the python extension for my C code as i 
have quite a big program in C.  I will prefer to write my program from 
scratch in python. I will be thankful if you can tell me how can i write an  
equivalent code in python for this sort of example i have mentioned.


Your link will be helpfull for me while writing my program in python. Thanks 
for that.

Waiting for your response.

Regards,


    From: Gerhard Häring <gh at ghaering.de>
To: python-list at python.org
Subject: Re: c to python
Date: Mon, 26 May 2003 20:22:57 +0200

Jimmy verma wrote:
    Hi !

I have a structure in c like this

struct ab
{
       int a;
       int b;
       int *c;
      struct d *d;
} AB;


And i am using it in my program like

void XYZ(int a , AB *b)

How can this kind of structure be translated in python code?

As far as I see, you can't. Python doesn't know about pointers, even with 
the struct module (http://python.org/doc/current/lib/module-struct.html).

    Your suggestions are welcomed.

It might be that you'll have to write a C extension to wrap your existing C 
code for use with Python.

If, however, you don't need any binary compatibility of your existing C code 
and you simply want an equivalent data structure in Python, then that's 
certainly easily doable.

We'd need to know why you have the 'int* c' in your C struct declaration, 
then.

-- Gerhard


--
http://mail.python.org/mailman/listinfo/python-list

_________________________________________________________________
Got a wish? Make it come true. 
http://server1.msn.co.in/msnleads/citibankpersonalloan/index.asp Best 
personal loans!






More information about the Python-list mailing list