Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to run C++ code
#1
hi guys

how i can run C++ code in python ?     Think
Reply
#2
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?
Reply
#3
yes...
I did not understand. I'm a simple example.
Reply
#4
You can't. You have to compile it in order to run it. You can use C objects, data, instances though.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#5
(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!  
Reply
#6
(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.
Recommended Tutorials:
Reply
#7
(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.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#8
This is similar in python:

for i in range(10):
    print(i)
Reply
#9
I've found this. I think it do what you want
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020