By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

Extending Python

P: n/a
I am looking for a good tutorial on how to extend python with C code. I
have an application built in C that I need to be able to use in Python.
I have searched through various sources, starting of course with the
Python site itself, and others, but I felt a bit lacking from the
Python site, it seems it was only made for those who installed the
source distribution, as for the other people... Anyways, thanks for the
help!

Oct 5 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Oct 05, Tuvas wrote:
I am looking for a good tutorial on how to extend python with C
code. I have an application built in C that I need to be able to use
in Python. I have searched through various sources, starting of
course with the Python site itself, and others, but I felt a bit
lacking from the Python site, it seems it was only made for those
who installed the source distribution, as for the other people...
Anyways, thanks for the help!


I have no experience with this, but I see that Alex Martelli's "Python
In A Nutshell" has quite a few pages on the subject.

--
Micah Elliott
<md*@micah.elliott.name>
Oct 5 '05 #2

P: n/a
"Tuvas" wrote:
I am looking for a good tutorial on how to extend python with C code. I
have an application built in C that I need to be able to use in Python.


http://docs.python.org/ext/ext.html

</F>

Oct 5 '05 #3

P: n/a
I own Python in a Nutshell, as one person pointed out. Alex Martelli
does a great job of introducing the concepts, as long as your'e familiar
with C. Additionally he covers wrapping (which is sounds like you're
trying to do) with SWIG, Pyrex, and a few other options. It's a great
book, I have used no other (save python docs) after my introduction.
I am looking for a good tutorial on how to extend python with C code. I
have an application built in C that I need to be able to use in Python.
I have searched through various sources, starting of course with the
Python site itself, and others, but I felt a bit lacking from the
Python site, it seems it was only made for those who installed the
source distribution, as for the other people... Anyways, thanks for the
help!

Oct 5 '05 #4

P: n/a
Hello Tuvas,
I am looking for a good tutorial on how to extend python with C code. I
have an application built in C that I need to be able to use in Python. http://www.swig.org/Doc1.3/Python.html#Python
I have searched through various sources, starting of course with the
Python site itself, and others, but I felt a bit lacking from the
Python site, it seems it was only made for those who installed the
source distribution, as for the other people... If you think something is missing from http://docs.python.org/ext/ext.html
please tell us.
Anyways, thanks for the help!

You're welcome.

Bye.
--
------------------------------------------------------------------------
Miki Tebeka <mt*****@qualcomm.com>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)

iD8DBQFDRPuk8jAdENsUuJsRAlQVAKChqGk3AnVMMEacu6LGAA UL6lOgnQCgsYVg
6jQL0QWL652rW7ixAJtTsNE=
=ONL3
-----END PGP SIGNATURE-----

Oct 6 '05 #5

P: n/a
Tuvas wrote:
I am looking for a good tutorial on how to extend python with C code. I
have an application built in C that I need to be able to use in Python.
I have searched through various sources, starting of course with the
Python site itself, and others, but I felt a bit lacking from the
Python site, it seems it was only made for those who installed the
source distribution, as for the other people... Anyways, thanks for the
help!


There are several options. Besides the manual way described in the
Python docs and SWIG that Miki mentioned, there is for instance the
option of using Pyrex. See http://ldots.org/pyrex-guide/ and
http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
Oct 6 '05 #6

P: n/a
On 5 Oct 2005 10:38:21 -0700, Tuvas <br***@yahoo.com> wrote:
I am looking for a good tutorial on how to extend python with C code. I
have an application built in C that I need to be able to use in Python.
I have searched through various sources, starting of course with the
Python site itself, and others, but I felt a bit lacking from the
Python site, it seems it was only made for those who installed the
source distribution, as for the other people...
So -- install the source distribution, then! You only want one or two
example files from it anyway. I have seen no need for it, personally.
You certainly don't have to compile your own Python to extend it.
Anyways, thanks for the
help!


Some work in progress, for what it's worth. Might serve as an example, but
don't trust it too much. It's yet-another literal interface to libpcap.

http://snipabacken.dyndns.org/~grahn/tmp/pcap2/

/Jorgen

--
// Jorgen Grahn <jgrahn@ Ph'nglui mglw'nafh Cthulhu
\X/ algonet.se> R'lyeh wgah'nagl fhtagn!
Oct 6 '05 #7

P: n/a
Perhaps it would be nice if they could include in the python documents
a link to download a sample code, the one that they were building in
the whole program, or at least a page that puts it all together? I get
a much better idea of how thing work when they are all put together
personally, and then explained individually. That would be the
simpliest thing that would help, and perhaps the files that are
included in the source distribution. Perhaps I might be the only python
user that didn't install the source code that wants to use extended C
applications, but I doubt it. Thanks for all of the help!

Oct 7 '05 #8

P: n/a
Micah Elliott <md*@micah.elliott.name> wrote:
On Oct 05, Tuvas wrote:
I am looking for a good tutorial on how to extend python with C
code. I have an application built in C that I need to be able to use
in Python. I have searched through various sources, starting of
course with the Python site itself, and others, but I felt a bit
lacking from the Python site, it seems it was only made for those
who installed the source distribution, as for the other people...
Anyways, thanks for the help!


I have no experience with this, but I see that Alex Martelli's "Python
In A Nutshell" has quite a few pages on the subject.


I also covered the same subject in a more tutorial (but less deep and
extended) way in articles for "Py" magazine, but I don't know if those
old issues of it are still in print.
Alex
Oct 8 '05 #9

P: n/a
Yup, still there, issues 1 and 2
http://pyzine.com/Issue002/index.html

Also recommend Dave Kuhlman's brief intro (open in your tabbed browser)
http://www.rexx.com/~dkuhlman/python...00000000000000
Alex Martelli wrote:
Micah Elliott <md*@micah.elliott.name> wrote:
On Oct 05, Tuvas wrote:
I am looking for a good tutorial on how to extend python with C
code. I have an application built in C that I need to be able to use
in Python. I have searched through various sources, starting of

I also covered the same subject in a more tutorial (but less deep and
extended) way in articles for "Py" magazine, but I don't know if those
old issues of it are still in print.
Alex


Oct 8 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.