compile()
Built-in FunctionPython 2.0+Advanced
Compiles source code into a code object for exec() or eval()
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
code = compile("print('Hello!')", "<string>", "exec") exec(code)
compile() is a built-in function that compiles source code into a code object for exec() or eval().
Try in PlaygroundTags
builtinfunctioncore