Python Forum
Compile c method in real time - 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: Compile c method in real time (/thread-15363.html)



Compile c method in real time - Battant - Jan-14-2019

Hello,

Here is my confidence
Python3.7
Windows 10

In ma code, I use c user32.dll throw a method in c language

My problem :

When I try to run the code I have an invalid syntax error in c method

Question :

How to say python to compile in real time c code when the interpreter read it ?


Thanks for your support

Best regards and hope your new year 2019

Battant


RE: Compile c method in real time - nilamo - Jan-14-2019

If you have a c compiler installed (such as llvm), then call it.
Python isn't a c compiler, it can't compile c code on it's own.


RE: Compile c method in real time - Gribouillis - Jan-14-2019

You can use cython which does this very well. (but it's not python, start with the FAQ)


RE: Compile c method in real time - Battant - Jan-14-2019

Hello,

Thanks for your answers.

I have found this code :

https://stackoverflow.com/questions/252417/how-can-i-use-a-dll-file-from-python

Question :

How could I run it ?

Thanks for your support

Best regards

Battant


RE: Compile c method in real time - Gribouillis - Jan-14-2019

The ctypes module doesn't compile C code. It is a foreign function interface which allows python code to call C library functions with some effort from the programmer on the python side. Start with the official documentation of module ctypes, then read online tutorials.