On 7 March 2014 14:29, Gabriele Brambilla <gb.gabrielebrambi...@gmail.com> wrote: > Hi, > in the next days I will receive a c++ code that I would like to run in > python (http://docs.python.org/2/extending/index.html). > It should be self consistent (no extraroutines). > I want to be ready to use it... Has someone some C++ code examples available > that I can try to run easily before getting that code?
Hi Gabriele, I recommend either Alan's suggestion of running the C++ code as an external application (with e.g. subprocess) or using cython to connect the C++ code to Python. Which is appropriate depends on what you need to do and how much flexibility you need from within the Python code. I learned C and C++ before Python and consider myself reasonably proficient in all 3 languages and capable of understanding (dis-)assembly and linkage and so on and I still find ctypes to be a bit of handful (I have less experience of cffi). Using Cython or just compiling the C++ code with an external compiler is much better for the error checking and so on. Using ctypes you get very little error-checking, just seg faults and corruption. Oscar _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor