<!-- Sema documentation — python
     Sema is a new AI-native, neurosymbolic programming language most models
     have not been trained on. Full corpus: https://sema.cortex.a2olabs.com/llms-full.txt
     Install language support: https://sema.cortex.a2olabs.com/install-skill/ -->

# python

> Governed persistent Python bridge operations.

> Generated by `sema doc` from the compiler's authoritative native-signature registry.

# python (native adapter)

Governed persistent Python worker — bring it in with `import python`; calls require their declared process effects.

# interop

## `python.import(module) -> any`

Import a Python module through the governed persistent worker and return an authenticated immutable object handle.

- domain: one nonempty dotted ASCII module name, at most 512 UTF-8 bytes
- shape: scalar
- returns: `any`
- effects: `ffi.call`
- example: `python.import("builtins")`

## `python.call(module, member, args) -> any`

Call one Python module member with explicit positional arguments and forwarded unique keyword arguments.

- domain: bounded dotted ASCII module, one ASCII member, explicit positional-argument list, and unique forwarded keywords
- shape: scalar
- returns: `any`
- keywords: any unique names
- effects: `ffi.call`
- example: `python.call("builtins", "len", [[1, 2]])`

## `python.method(object, member, args) -> any`

Resolve and call one exact member on an authenticated Python object handle.

- domain: authenticated Python handle, one ASCII member, explicit positional-argument list, and unique forwarded keywords
- shape: scalar
- returns: `any`
- keywords: any unique names
- effects: `ffi.call`
- example: `python.method(python.import("builtins"), "dict", [])`

## `python.attr(object, member) -> any`

Resolve one exact member on an authenticated Python object handle.

- domain: authenticated Python handle and one ASCII member at most 256 UTF-8 bytes
- shape: scalar
- returns: `any`
- effects: `ffi.call`
- example: `python.attr(python.import("builtins"), "len")`

## `python.str(object) -> str`

Return Python's bounded string representation of an authenticated handle.

- domain: authenticated Python object handle
- shape: scalar
- returns: `str`
- effects: `ffi.call`
- example: `python.str(python.import("builtins"))`

## `python.free(object) -> any`

Release an authenticated Python object handle and propagate worker failures.

- domain: authenticated Python object handle
- shape: scalar
- returns: `any`
- effects: `ffi.call`
- example: `python.free(python.import("builtins"))`
