Python Forum
How to run C++ code - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to run C++ code (/thread-1559.html)



How to run C++ code - sajley - Jan-12-2017

hi guys

how i can run C++ code in python ?     Think


RE: How to run C++ code - j.crater - Jan-12-2017

Hello,

a quick search gave me these results of people with same question:
http://stackoverflow.com/questions/145270/calling-c-c-from-python
http://stackoverflow.com/questions/13498445/calling-a-c-functions-through-a-python-script
and docs page:
https://docs.python.org/3.5/extending/extending.html

Does any of those links contain the information you are looking for?


RE: How to run C++ code - sajley - Jan-12-2017

yes...
I did not understand. I'm a simple example.


RE: How to run C++ code - wavic - Jan-12-2017

You can't. You have to compile it in order to run it. You can use C objects, data, instances though.


RE: How to run C++ code - sajley - Jan-12-2017

(Jan-12-2017, 11:29 AM)wavic Wrote: You can't. You have to compile it in order to run it. You can use C objects, data, instances though.

I can not use C++ functions in python ?  if yes, how i can call C++ Functions in python.    Huh

2- i can not run this code (below code)  in python ??  :  if yes, how i can?    

(for int i = 0; i < 10 ; i++) {
cout<< i;
}

sorry, i understand a little english   Undecided

i see in internet and book , i can run c++ code in python, but i dont understand how i can run!  


RE: How to run C++ code - metulburr - Jan-12-2017

(Jan-12-2017, 12:32 PM)sajley Wrote: 2- i can not run this code (below code)  in python ??  :  if yes, how i can?    

(for int i = 0; i < 10 ; i++) {
cout<< i;
}

If this is all you are running or similar, just change your print line for C and make an extension.


RE: How to run C++ code - wavic - Jan-12-2017

(Jan-12-2017, 12:32 PM)sajley Wrote: 2- i can not run this code (below code)  in python ??  :  if yes, how i can?    
Make it a function and use it. I don't know how you can call a C functions in Python because I never did it before.


RE: How to run C++ code - Kebap - Jan-13-2017

This is similar in python:

for i in range(10):
    print(i)



RE: How to run C++ code - wavic - Jan-14-2017

I've found this. I think it do what you want