2

it is possible to create a program which is written in python and C++ by using cython How would you use this class written in python (if possible) inside some cpp file (which uses the "calcuations" function, and prints "happy birthday"), by using cython?

file1.py:-

class mathClass:

def __init__(self,number):
    self.number = number

def calcuations(self):
    self.number = self.number + 1
    print(self.number)

math = mathClass(10)

Edit

Don't miss understand me, but "have you heard about cython" is often mentioned in stackoverflow, and I did some research, and by my understading (I beg you, correct me if I am wrong), cython is a language which is similar to python and can be interpreted by c++ or by python, but I am not sure if it can actually be used to link python to c++ (I didn't managed to find any tutorials/examples)

MeHow
  • 133
  • 1
  • 1
  • 8
  • You might want to check out Cython http://cython.org/. There's a learning curve but it's a very powerful language. – Paul Cornelius Sep 09 '16 at 23:32
  • I know of the other way around.. http://www.boost.org/doc/libs/1_59_0/libs/python/doc/ – Vasif Sep 09 '16 at 23:34
  • I did, and by my understading (plz correct me if I am wrong), cython is a language which is similar to python and can be interpreted by c++ or by python, but I am not sure if it can link python to c++ (I didn't managed to find any tutorials/examples) response to Paul cornelius – MeHow Sep 09 '16 at 23:36
  • Have you tried [swig](http://www.swig.org/Doc1.3/Python.html)? It is easy to use and the learning curve is not that hard. – ConsistentProgrammer Sep 09 '16 at 23:41
  • @MeHow Cython can be used to link Python to C/C++. Cython code is syntactically similar to Python so it cannot be run through a C/C++ compiler. Example Cython to C++: http://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html – Paul Cornelius Sep 09 '16 at 23:51

0 Answers0