Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to compile other programming languages using python?

I want to execute some other programming languages (e.g. C++ / java / kotlin) inside python and get the output.
is there any library or solution for this?
I dont want to create new programming language . I just want to compile codes.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

you can use run, PIPE function from subprocess library and system function from os library like this:

from os import system as sys
from subprocess import run, PIPE

# Example for c language with gcc compiler
sys('gcc ./something.c -o out')
out = run(["./out"], stdout=PIPE).stdout.decode("UTF-8")
print(out)

you can use run and system function in macos and linux, i think you can use it in windows too but i’m not sure

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading