Extending Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tuvas

    #1

    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!

  • Micah Elliott

    #2
    Re: Extending Python

    On Oct 05, Tuvas wrote:[color=blue]
    > 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![/color]

    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
    <mde@micah.elli ott.name>

    Comment

    • Fredrik Lundh

      #3
      Re: Extending Python

      "Tuvas" wrote:
      [color=blue]
      >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.[/color]



      </F>



      Comment

      • Brandon K

        #4
        Re: Extending Python

        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.[color=blue]
        > 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!
        >
        >[/color]


        Comment

        • Miki Tebeka

          #5
          Re: Extending Python

          Hello Tuvas,
          [color=blue]
          > 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.[/color]

          [color=blue]
          > 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... [/color]
          If you think something is missing from http://docs.python.org/ext/ext.html
          please tell us.
          [color=blue]
          > Anyways, thanks for the help![/color]
          You're welcome.

          Bye.
          --
          ------------------------------------------------------------------------
          Miki Tebeka <mtebeka@qualco mm.com>

          The only difference between children and adults is the price of the toys

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

          iD8DBQFDRPuk8jA dENsUuJsRAlQVAK ChqGk3AnVMMEacu 6LGAAUL6lOgnQCg sYVg
          6jQL0QWL652rW7i xAJtTsNE=
          =ONL3
          -----END PGP SIGNATURE-----

          Comment

          • Magnus Lycka

            #6
            Re: Extending Python

            Tuvas wrote:[color=blue]
            > 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![/color]

            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

            Comment

            • Jorgen Grahn

              #7
              Re: Extending Python

              On 5 Oct 2005 10:38:21 -0700, Tuvas <brp13@yahoo.co m> wrote:[color=blue]
              > 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...[/color]

              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.
              [color=blue]
              > Anyways, thanks for the
              > help![/color]

              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.



              /Jorgen

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

              Comment

              • Tuvas

                #8
                Re: Extending Python

                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!

                Comment

                • Alex Martelli

                  #9
                  Re: Extending Python

                  Micah Elliott <mde@micah.elli ott.name> wrote:
                  [color=blue]
                  > On Oct 05, Tuvas wrote:[color=green]
                  > > 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![/color]
                  >
                  > 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.[/color]

                  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

                  Comment

                  • gene tani

                    #10
                    Re: Extending Python

                    Yup, still there, issues 1 and 2
                    Cette page n'existe pas ou a été déplacée.


                    Also recommend Dave Kuhlman's brief intro (open in your tabbed browser)



                    Alex Martelli wrote:[color=blue]
                    > Micah Elliott <mde@micah.elli ott.name> wrote:
                    >[color=green]
                    > > On Oct 05, Tuvas wrote:[color=darkred]
                    > > > 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[/color][/color][/color]
                    [color=blue]
                    >
                    > 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[/color]

                    Comment

                    Working...