1,105,288 Community Members

how to use c program in Python

Member Avatar
Newbie Poster
1 post since Sep 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]

hi to all
i want to use c program in python
or in other way i want to run c program from python

Member Avatar
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]

Run an external program from within Python code with
subprocess.call(["program-name", "arg1", "arg2"])
rather than os.system("program-name arg1 arg2")
since os.system() does not allow the Python program
to run in the background, whereas subprocess does.

Example ...

# play a midi file with a small external midiplayer:
# from http://www.kanatachoralsociety.ca/memberscorner/AKoffPlr.exe
# mplayer2.exe works too, but not wmplayer.exe
import subprocess
subprocess.call(["C:/Midi_stuff/AKoffPlr.exe", "DaarG.mid"])
Question Answered as of 6 Months Ago by vegaseat
This question has already been solved: Start a new discussion instead
Start New Discussion
Tags Related to this Article