Results 1 to 4 of 4

Thread: Combining C++ and Python

  1. #1
    Join Date
    Mar 2011
    Beans
    56

    Combining C++ and Python

    I have written a todo task manager in C++. I want to save the tasks into an xml file. So i need a XML library. I tried libxml++. let us keep it aside. I want to use python for doing this job. can I combine python with C++. is there anyway to combine two languages in single program..
    Vanangamudi
    Minniyal Poriyalan
    Puduvai,Bharatham.

  2. #2
    Join Date
    Jan 2010
    Location
    Kolkata India
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Combining C++ and Python

    Have not tried it , but boost could be of help .
    http://www.boost.org/doc/libs/1_36_0...doc/index.html
    “Progress is made by lazy men looking for easier ways to do things”
    — Robert A. Heinlein

  3. #3
    Join Date
    Mar 2009
    Location
    Western Hemisphere.
    Beans
    136
    Distro
    Ubuntu

    Re: Combining C++ and Python

    Quote Originally Posted by vanangamudi View Post
    can I combine python with C++. is there anyway to combine two languages in single program..
    Yup.

    Python is written in C, and you can embed Python code in C or C++ using the Python C API. You can also extend Python with a C or C++ module.

    The documentation on this topic is quite extensive, so have a look!

    EDIT: All that said, embedding isn't a great option because converting data from Python types to C types is very fiddly, so if your xml isn't very simple, it could be a good bit of work. Extending Python is an option, but it's a poor fit if you've already implemented everything in C++. Personally, I'd have done the whole project in Python, but at this point I would use a C++ based XML library.
    Last edited by LemursDontExist; April 29th, 2012 at 03:39 PM. Reason: More thoughts

  4. #4
    Join Date
    Mar 2012
    Beans
    6

    Re: Combining C++ and Python

    I dont know much about python but i know c++. Only thing i can recomend you is that you google Cython which is a programing langauge to simplify writing c and c++ extension modules.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •