473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Extending Python

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
9 1856
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
"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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alicia Haumann | last post by:
I accidentally sent this to webmaster@python.org, so this could be a duplicate if "webmaster" forwards it to this list. :{ Hi, there. Thanks for any help that can be offered. I've been...
1
by: Richard Townsend | last post by:
In the "Extending and Embedding" part of the Python documentation: section 5.4 "Extending Embedded Python" - it describes how to use a Python extension module from Python that is embedded in a C...
5
by: vbgunz | last post by:
Hello everyone. I own two books. Learning Python and Python in a nutshell. When cross referencing the two books to try and clarify the ideas behind extending methods and delegates, this is where...
1
by: jeremito | last post by:
I am trying to learn how to extend and/or embed Python. I have looked at the document "Extending and Embedding the Python Interpreter" and also "Python/C API Reference Manual. In the examples...
0
by: Tim Spens | last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote: I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.