Skip to main content
Log in

Mojo trait

ConvertibleFromPython

Denotes a type that can attempt construction from a read-only Python object.

Implemented traits

AnyType, Copyable, Movable, UnknownDestructibility

Methods

__init__

__init__(out self: _Self, obj: PythonObject)

Attempt to construct an instance of this object from a read-only Python value.

Args:

  • obj (PythonObject): The Python object to convert from.

Raises:

If conversion was not successful.

__copyinit__

__copyinit__(out self: _Self, existing: _Self, /)

Create a new instance of the value by copying an existing one.

Args:

  • existing (_Self): The value to copy.

__moveinit__

__moveinit__(out self: _Self, owned existing: _Self, /)

Create a new instance of the value by moving the value of another.

Args:

  • existing (_Self): The value to move.