I want to execute assembly code inside a python script. Is that possible?
In C programming would be like this
static inline getesp(){
__asm__("mov %esp, %eax");
}
But how to do that with Python? Is it possible?
One way you could do this would be to write a (C) extension for Python. You can take a look at this documentation for full details of how to do that.
Another way of developing C-based Python extensions would be to interface directly with an external library using the ctypes module.
In any case, you'd need some C code compiled into either a library or an extension and a way to call it from Python. Clearly for what you want to achieve this is probably not optimal but actually its not that much work to expose a few functions.