Python Forum

Full Version: How to run C++ code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi guys

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

a quick search gave me these results of people with same question:
http://stackoverflow.com/questions/14527...rom-python
http://stackoverflow.com/questions/13498...hon-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?
yes...
I did not understand. I'm a simple example.
You can't. You have to compile it in order to run it. You can use C objects, data, instances though.
(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!  
(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.
(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.
This is similar in python:

for i in range(10):
    print(i)
I've found this. I think it do what you want