Get hex code from x86 Assembly code on Python

By CAPSTONE/pydasm library, I can generate assemble code from hex code. but I want to assemble code(x86). not dissemble.

I want to get hex code from assemble code with code base. Is there any library to assemble on Python?

Answers

You probably need a compiler. I'm not aware of pure asm embedding but you could try to embed asm in C code, and embed C in python. To embed C in python you have few choices. Some of them are pyinline and cffi