mojo-python-interop - Mojo Python Interoperation Guide
Write Mojo code interoperating with Python using current syntax
Tags
Updated: 2026-03-26Capabilities
Typical Inputs
Typical Outputs
What this skill does
- import Python modules
- convert PythonObject to Mojo
- convert Mojo to PythonObject
- build Python collections
- access PythonObject attributes
- iterate Python collections
- evaluate Python code
- handle Python exceptions
- build Python extension modules
- export Mojo functions
- export Mojo types with methods
- support kwargs in methods
- import Mojo modules from Python
Inputs
- Python environment
- Mojo code
- Python libraries
- Mojo types and functions
Outputs
- shared library files
- Python modules
- Python objects
- converted Mojo values
- Python exceptions
Requirements
- Mojo compiler environment
- Python runtime
- std.python module
