Python code -> to C code

Steven Taschuk staschuk at telusplanet.net
Tue Apr 29 12:21:07 EDT 2003


Quoth Garrison Tsang:
  [...]
> There is a program written in Python by a friend.  It takes in a file and
> decrypts it , which I would like to integrate into a C program I am writing.

Integrating Python code into a C program is called "embedding",
that is, embedding the Python interpreter in your C program so the
interpreter can run the Python code for you at request.

> I want to see how the python code was implemented and whether I can
> implement it is C.

Now this seems like a completely different and unrelated
objective.  For this, it seems to me you need to learn enough
Python to read your friend's program, then translate the algorithm
into C.

In principle such conversions could be done automatically, but
Python's dynamic typing (etc.) would probably entail very verbose
output.  Better to translate it by hand.

(Of course, you could just write *your* program in Python.  You
say you don't know any Python but are very familiar with C.  I
will echo others and say that you'll be able to get things done in
Python in a matter of hours, you'll be effective with it in a
matter of days, and familiar with it in a matter of weeks.)

-- 
Steven Taschuk              Aral: "Confusion to the enemy, boy."
staschuk at telusplanet.net    Mark: "Turn-about is fair play, sir."
                             -- _Mirror Dance_, Lois McMaster Bujold





More information about the Python-list mailing list