# pyo3::prelude::Py - Rust
A Python object of known type T.
Keywords: rust, rustlang, rust-lang, Py

# Struct pyo3::prelude::Py [−] [src]

    #[repr(transparent)]pub struct Py<T>(_, _);

A Python object of known type T.

Accessing this object is thread-safe, since any access to its API requires a `Python<'py>` GIL token. There are a few different ways to use the Python object contained:

- `Py::as_ref` to borrow a GIL-bound reference to the contained object.
- `Py::borrow`, `Py::try_borrow`, `Py::borrow_mut`, or `Py::try_borrow_mut`, to directly access a `#[pyclass]` value (which has RefCell-like behavior, see the `PyCell` guide entry ).
- Use methods directly on `Py`, such as `Py::call` and `Py::call_method`.

See the guide for an explanation of the different Python object types.

## Implementations

### `impl<T> Py<T> where
T: PyClass,` [src]

#### `pub fn new(
py: Python<'_>,
value: impl Into<PyClassInitializer<T>>
) -> PyResult<Py<T>> where
T::BaseLayout: PyBorrowFlagLayout<T::BaseType>,` [src]

Create a new instance `Py<T>` of a `#[pyclass]` on the Python heap.

### `impl<T> Py<T> where
T: PyTypeInfo,` [src]

#### `pub fn as_ref<'py>(&'py self, _py: Python<'py>) -> &'py T::AsRefTarget` [src]

Borrows a GIL-bound reference to the contained `T`. By binding to the GIL lifetime, this allows the GIL-bound reference to not require `Python` for any of its methods.

For native types, this reference is `&T`. For pyclasses, this is `&PyCell<T>`.

# Examples

Get access to `&PyList` from `Py<PyList>`:

    let list: Py<PyList> = PyList::empty(py).into();
    let list: &PyList = list.as_ref(py);
    assert_eq!(list.len(), 0);

Get access to `&PyCell<MyClass>` from `Py<MyClass>`:

    #[pyclass]
    struct MyClass { }
    let my_class: Py<MyClass> = Py::new(py, MyClass { }).unwrap();
    let my_class_cell: &PyCell<MyClass> = my_class.as_ref(py);
    assert!(my_class_cell.try_borrow().is_ok());

#### `pub fn into_ref(self, py: Python<'_>) -> &T::AsRefTarget` [src]

Similar to `as_ref`, and also consumes this `Py` and registers the Python object reference in PyO3’s object storage. The reference count for the Python object will not be decreased until the GIL lifetime ends.

# Example

Useful when returning GIL-bound references from functions. In the snippet below, note that the `'py` lifetime of the input GIL lifetime is also given to the returned reference:

    fn new_py_any<'py>(py: Python<'py>, value: impl IntoPy<PyObject>) -> &'py PyAny {
        let obj: PyObject = value.into_py(py);

        // .as_ref(py) would not be suitable here, because a reference to `obj` may not be
        // returned from the function.
        obj.into_ref(py)
    }

### `impl<T> Py<T> where
T: PyClass,` [src]

#### `pub fn borrow<'py>(&'py self, py: Python<'py>) -> PyRef<'py, T>` [src]

Immutably borrows the value `T`. This borrow lasts untill the returned `PyRef` exists.

Equivalent to `self.as_ref(py).borrow()` - see `PyCell::borrow`

# Panics

Panics if the value is currently mutably borrowed. For a non-panicking variant, use `try_borrow`.

#### `pub fn borrow_mut<'py>(&'py self, py: Python<'py>) -> PyRefMut<'py, T>` [src]

Mutably borrows the value `T`. This borrow lasts untill the returned `PyRefMut` exists.

Equivalent to `self.as_ref(py).borrow_mut()` - see `PyCell::borrow_mut`

# Panics

Panics if the value is currently mutably borrowed. For a non-panicking variant, use `try_borrow_mut`.

#### `pub fn try_borrow<'py>(
&'py self,
py: Python<'py>
) -> Result<PyRef<'py, T>, PyBorrowError>` [src]

Immutably borrows the value `T`, returning an error if the value is currently mutably borrowed. This borrow lasts untill the returned `PyRef` exists.

This is the non-panicking variant of `borrow`.

Equivalent to `self.as_ref(py).try_borrow()` - see `PyCell::try_borrow`

#### `pub fn try_borrow_mut<'py>(
&'py self,
py: Python<'py>
) -> Result<PyRefMut<'py, T>, PyBorrowMutError>` [src]

Mutably borrows the value `T`, returning an error if the value is currently borrowed. This borrow lasts untill the returned `PyRefMut` exists.

This is the non-panicking variant of `borrow_mut`.

Equivalent to `self.as_ref(py).try_borrow_mut() - see [`PyCell::try_borrow_mut`](../pycell/struct.PyCell.html#method.try_borrow_mut)

### `impl<T> Py<T>` [src]

#### `pub fn get_refcnt(&self, _py: Python<'_>) -> isize` [src]

Gets the reference count of the `ffi::PyObject` pointer.

#### `pub fn clone_ref(&self, py: Python<'_>) -> Py<T>` [src]

Clones self by calling `Py_INCREF()` on the ptr.

#### `pub fn is_none(&self, _py: Python<'_>) -> bool` [src]

Returns whether the object is considered to be None.

This is equivalent to the Python expression `self is None`.

#### `pub fn is_true(&self, py: Python<'_>) -> PyResult<bool>` [src]

Returns whether the object is considered to be true.

This is equivalent to the Python expression `bool(self)`.

#### `pub fn extract<'p, D>(&'p self, py: Python<'p>) -> PyResult<D> where
D: FromPyObject<'p>,` [src]

Extracts some type from the Python object.

This is a wrapper function around `FromPyObject::extract()`.

#### `pub fn getattr<N>(&self, py: Python<'_>, attr_name: N) -> PyResult<PyObject> where
N: ToPyObject,` [src]

Retrieves an attribute value.

This is equivalent to the Python expression `self.attr_name`.

#### `pub fn call(
&self,
py: Python<'_>,
args: impl IntoPy<Py<PyTuple>>,
kwargs: Option<&PyDict>
) -> PyResult<PyObject>` [src]

Calls the object.

This is equivalent to the Python expression `self(*args, **kwargs)`.

#### `pub fn call1(
&self,
py: Python<'_>,
args: impl IntoPy<Py<PyTuple>>
) -> PyResult<PyObject>` [src]

Calls the object with only positional arguments.

This is equivalent to the Python expression `self(*args)`.

#### `pub fn call0(&self, py: Python<'_>) -> PyResult<PyObject>` [src]

Calls the object without arguments.

This is equivalent to the Python expression `self()`.

#### `pub fn call_method(
&self,
py: Python<'_>,
name: &str,
args: impl IntoPy<Py<PyTuple>>,
kwargs: Option<&PyDict>
) -> PyResult<PyObject>` [src]

Calls a method on the object.

This is equivalent to the Python expression `self.name(*args, **kwargs)`.

#### `pub fn call_method1(
&self,
py: Python<'_>,
name: &str,
args: impl IntoPy<Py<PyTuple>>
) -> PyResult<PyObject>` [src]

Calls a method on the object with only positional arguments.

This is equivalent to the Python expression `self.name(*args)`.

#### `pub fn call_method0(&self, py: Python<'_>, name: &str) -> PyResult<PyObject>` [src]

Calls a method on the object with no arguments.

This is equivalent to the Python expression `self.name()`.

#### `pub unsafe fn from_owned_ptr(py: Python<'_>, ptr: *mut PyObject) -> Py<T>` [src]

Create a `Py<T>` instance by taking ownership of the given FFI pointer.

# Safety

`ptr` must be a pointer to a Python object of type T.

Callers must own the object referred to by `ptr`, as this function implicitly takes ownership of that object.

# Panics

Panics if `ptr` is null.

#### `pub unsafe fn from_owned_ptr_or_panic(
py: Python<'_>,
ptr: *mut PyObject
) -> Py<T>` [src]

👎 Deprecated:

this is a deprecated alias for Py::from_owned_ptr

Deprecated alias for `from_owned_ptr`.

# Safety

`ptr` must be a pointer to a Python object of type T.

Callers must own the object referred to by `ptr`, as this function implicitly takes ownership of that object.

#### `pub unsafe fn from_owned_ptr_or_err(
py: Python<'_>,
ptr: *mut PyObject
) -> PyResult<Py<T>>` [src]

Create a `Py<T>` instance by taking ownership of the given FFI pointer.

If `ptr` is null then the current Python exception is fetched as a `PyErr`.

# Safety

If non-null, `ptr` must be a pointer to a Python object of type T.

#### `pub unsafe fn from_owned_ptr_or_opt(
_py: Python<'_>,
ptr: *mut PyObject
) -> Option<Self>` [src]

Create a `Py<T>` instance by taking ownership of the given FFI pointer.

If `ptr` is null then `None` is returned.

# Safety

If non-null, `ptr` must be a pointer to a Python object of type T.

#### `pub unsafe fn from_borrowed_ptr(py: Python<'_>, ptr: *mut PyObject) -> Py<T>` [src]

Create a `Py<T>` instance by creating a new reference from the given FFI pointer.

# Safety

`ptr` must be a pointer to a Python object of type T.

# Panics

Panics if `ptr` is null.

#### `pub unsafe fn from_borrowed_ptr_or_err(
py: Python<'_>,
ptr: *mut PyObject
) -> PyResult<Self>` [src]

Create a `Py<T>` instance by creating a new reference from the given FFI pointer.

If `ptr` is null then the current Python exception is fetched as a `PyErr`.

# Safety

`ptr` must be a pointer to a Python object of type T.

#### `pub unsafe fn from_borrowed_ptr_or_opt(
_py: Python<'_>,
ptr: *mut PyObject
) -> Option<Self>` [src]

Create a `Py<T>` instance by creating a new reference from the given FFI pointer.

If `ptr` is null then `None` is returned.

# Safety

`ptr` must be a pointer to a Python object of type T.

### `impl Py<PyAny>` [src]

#### `pub fn cast_as<'p, D>(
&'p self,
py: Python<'p>
) -> Result<&'p D, PyDowncastError<'_>> where
D: PyTryFrom<'p>,` [src]

Casts the PyObject to a concrete Python object type.

This can cast only to native Python types, not types implemented in Rust. For a more flexible alternative, see `Py::extract`.

## Trait Implementations

### `impl<T> AsPyPointer for Py<T>` [src]

#### `fn as_ptr(&self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a borrowed pointer.

### `impl<T> Clone for Py<T>` [src]

#### `fn clone(&self) -> Self` [src]

Returns a copy of the value. Read more

#### `pub fn clone_from(&mut self, source: &Self)`1.0.0 [src]

Performs copy-assignment from `source`. Read more

### `impl<T> Debug for Py<T>` [src]

#### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` [src]

Formats the value using the given formatter. Read more

### `impl<T> Display for Py<T> where
T: PyTypeInfo,
T::AsRefTarget: Display,` [src]

#### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` [src]

Formats the value using the given formatter. Read more

### `impl<T> Drop for Py<T>` [src]

Dropping a `Py` instance decrements the reference count on the object by 1.

#### `fn drop(&mut self)` [src]

Executes the destructor for this type. Read more

### `impl<T> Error for Py<T> where
T: Error + PyTypeInfo,
T::AsRefTarget: Display,` [src]

Py<T> can be used as an error when T is an Error.

However for GIL lifetime reasons, cause() cannot be implemented for Py<T>. Use .as_ref() to get the GIL-scoped error if you need to inspect the cause.

#### `pub fn source(&self) -> Option<&(dyn Error + 'static)>`1.30.0 [src]

The lower-level source of this error, if any. Read more

#### `pub fn backtrace(&self) -> Option<&Backtrace>` [src]

🔬 This is a nightly-only experimental API. (`backtrace`)

Returns a stack backtrace, if available, of where this error occurred. Read more

#### `pub fn description(&self) -> &str` 1.0.0 [src]

👎 Deprecated since 1.42.0:

use the Display impl or to_string()

Read more

#### `pub fn cause(&self) -> Option<&dyn Error>`1.0.0 [src]

👎 Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

### `impl From<&'_ CancelledError> for Py<CancelledError>` [src]

#### `fn from(other: &CancelledError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ IncompleteReadError> for Py<IncompleteReadError>` [src]

#### `fn from(other: &IncompleteReadError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ InvalidStateError> for Py<InvalidStateError>` [src]

#### `fn from(other: &InvalidStateError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ LimitOverrunError> for Py<LimitOverrunError>` [src]

#### `fn from(other: &LimitOverrunError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PanicException> for Py<PanicException>` [src]

#### `fn from(other: &PanicException) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyArithmeticError> for Py<PyArithmeticError>` [src]

#### `fn from(other: &PyArithmeticError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyAssertionError> for Py<PyAssertionError>` [src]

#### `fn from(other: &PyAssertionError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyAttributeError> for Py<PyAttributeError>` [src]

#### `fn from(other: &PyAttributeError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyBaseException> for Py<PyBaseException>` [src]

#### `fn from(other: &PyBaseException) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyBlockingIOError> for Py<PyBlockingIOError>` [src]

#### `fn from(other: &PyBlockingIOError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyBool> for Py<PyBool>` [src]

#### `fn from(other: &PyBool) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyBrokenPipeError> for Py<PyBrokenPipeError>` [src]

#### `fn from(other: &PyBrokenPipeError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyBufferError> for Py<PyBufferError>` [src]

#### `fn from(other: &PyBufferError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyByteArray> for Py<PyByteArray>` [src]

#### `fn from(other: &PyByteArray) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyBytes> for Py<PyBytes>` [src]

#### `fn from(other: &PyBytes) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyCFunction> for Py<PyCFunction>` [src]

#### `fn from(other: &PyCFunction) -> Self` [src]

Performs the conversion.

### `impl<'a, T> From<&'_ PyCell<T>> for Py<T> where
T: PyClass,` [src]

#### `fn from(cell: &PyCell<T>) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyChildProcessError> for Py<PyChildProcessError>` [src]

#### `fn from(other: &PyChildProcessError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyComplex> for Py<PyComplex>` [src]

#### `fn from(other: &PyComplex) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyConnectionAbortedError> for Py<PyConnectionAbortedError>` [src]

#### `fn from(other: &PyConnectionAbortedError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyConnectionError> for Py<PyConnectionError>` [src]

#### `fn from(other: &PyConnectionError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyConnectionRefusedError> for Py<PyConnectionRefusedError>` [src]

#### `fn from(other: &PyConnectionRefusedError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyConnectionResetError> for Py<PyConnectionResetError>` [src]

#### `fn from(other: &PyConnectionResetError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyDate> for Py<PyDate>` [src]

#### `fn from(other: &PyDate) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyDateTime> for Py<PyDateTime>` [src]

#### `fn from(other: &PyDateTime) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyDelta> for Py<PyDelta>` [src]

#### `fn from(other: &PyDelta) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyDict> for Py<PyDict>` [src]

#### `fn from(other: &PyDict) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyEOFError> for Py<PyEOFError>` [src]

#### `fn from(other: &PyEOFError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyEnvironmentError> for Py<PyEnvironmentError>` [src]

#### `fn from(other: &PyEnvironmentError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyException> for Py<PyException>` [src]

#### `fn from(other: &PyException) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyFileExistsError> for Py<PyFileExistsError>` [src]

#### `fn from(other: &PyFileExistsError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyFileNotFoundError> for Py<PyFileNotFoundError>` [src]

#### `fn from(other: &PyFileNotFoundError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyFloat> for Py<PyFloat>` [src]

#### `fn from(other: &PyFloat) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyFloatingPointError> for Py<PyFloatingPointError>` [src]

#### `fn from(other: &PyFloatingPointError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyFrozenSet> for Py<PyFrozenSet>` [src]

#### `fn from(other: &PyFrozenSet) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyFunction> for Py<PyFunction>` [src]

#### `fn from(other: &PyFunction) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyGeneratorExit> for Py<PyGeneratorExit>` [src]

#### `fn from(other: &PyGeneratorExit) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyIOError> for Py<PyIOError>` [src]

#### `fn from(other: &PyIOError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyImportError> for Py<PyImportError>` [src]

#### `fn from(other: &PyImportError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyIndexError> for Py<PyIndexError>` [src]

#### `fn from(other: &PyIndexError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyInterruptedError> for Py<PyInterruptedError>` [src]

#### `fn from(other: &PyInterruptedError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyIsADirectoryError> for Py<PyIsADirectoryError>` [src]

#### `fn from(other: &PyIsADirectoryError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyIterator> for Py<PyIterator>` [src]

#### `fn from(other: &PyIterator) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyKeyError> for Py<PyKeyError>` [src]

#### `fn from(other: &PyKeyError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyKeyboardInterrupt> for Py<PyKeyboardInterrupt>` [src]

#### `fn from(other: &PyKeyboardInterrupt) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyList> for Py<PyList>` [src]

#### `fn from(other: &PyList) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyLong> for Py<PyLong>` [src]

#### `fn from(other: &PyLong) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyLookupError> for Py<PyLookupError>` [src]

#### `fn from(other: &PyLookupError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyMemoryError> for Py<PyMemoryError>` [src]

#### `fn from(other: &PyMemoryError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyModule> for Py<PyModule>` [src]

#### `fn from(other: &PyModule) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyModuleNotFoundError> for Py<PyModuleNotFoundError>` [src]

#### `fn from(other: &PyModuleNotFoundError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyNameError> for Py<PyNameError>` [src]

#### `fn from(other: &PyNameError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyNotADirectoryError> for Py<PyNotADirectoryError>` [src]

#### `fn from(other: &PyNotADirectoryError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyNotImplementedError> for Py<PyNotImplementedError>` [src]

#### `fn from(other: &PyNotImplementedError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyOSError> for Py<PyOSError>` [src]

#### `fn from(other: &PyOSError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyOverflowError> for Py<PyOverflowError>` [src]

#### `fn from(other: &PyOverflowError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyPermissionError> for Py<PyPermissionError>` [src]

#### `fn from(other: &PyPermissionError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyProcessLookupError> for Py<PyProcessLookupError>` [src]

#### `fn from(other: &PyProcessLookupError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyRecursionError> for Py<PyRecursionError>` [src]

#### `fn from(other: &PyRecursionError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyReferenceError> for Py<PyReferenceError>` [src]

#### `fn from(other: &PyReferenceError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyRuntimeError> for Py<PyRuntimeError>` [src]

#### `fn from(other: &PyRuntimeError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PySequence> for Py<PySequence>` [src]

#### `fn from(other: &PySequence) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PySet> for Py<PySet>` [src]

#### `fn from(other: &PySet) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PySlice> for Py<PySlice>` [src]

#### `fn from(other: &PySlice) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyStopAsyncIteration> for Py<PyStopAsyncIteration>` [src]

#### `fn from(other: &PyStopAsyncIteration) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyStopIteration> for Py<PyStopIteration>` [src]

#### `fn from(other: &PyStopIteration) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyString> for Py<PyString>` [src]

#### `fn from(other: &PyString) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PySyntaxError> for Py<PySyntaxError>` [src]

#### `fn from(other: &PySyntaxError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PySystemError> for Py<PySystemError>` [src]

#### `fn from(other: &PySystemError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PySystemExit> for Py<PySystemExit>` [src]

#### `fn from(other: &PySystemExit) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyTime> for Py<PyTime>` [src]

#### `fn from(other: &PyTime) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyTimeoutError> for Py<PyTimeoutError>` [src]

#### `fn from(other: &PyTimeoutError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyTuple> for Py<PyTuple>` [src]

#### `fn from(other: &PyTuple) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyType> for Py<PyType>` [src]

#### `fn from(other: &PyType) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyTypeError> for Py<PyTypeError>` [src]

#### `fn from(other: &PyTypeError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyTzInfo> for Py<PyTzInfo>` [src]

#### `fn from(other: &PyTzInfo) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyUnboundLocalError> for Py<PyUnboundLocalError>` [src]

#### `fn from(other: &PyUnboundLocalError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyUnicodeDecodeError> for Py<PyUnicodeDecodeError>` [src]

#### `fn from(other: &PyUnicodeDecodeError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyUnicodeEncodeError> for Py<PyUnicodeEncodeError>` [src]

#### `fn from(other: &PyUnicodeEncodeError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyUnicodeError> for Py<PyUnicodeError>` [src]

#### `fn from(other: &PyUnicodeError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyUnicodeTranslateError> for Py<PyUnicodeTranslateError>` [src]

#### `fn from(other: &PyUnicodeTranslateError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyValueError> for Py<PyValueError>` [src]

#### `fn from(other: &PyValueError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ PyZeroDivisionError> for Py<PyZeroDivisionError>` [src]

#### `fn from(other: &PyZeroDivisionError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ QueueEmpty> for Py<QueueEmpty>` [src]

#### `fn from(other: &QueueEmpty) -> Self` [src]

Performs the conversion.

### `impl From<&'_ QueueFull> for Py<QueueFull>` [src]

#### `fn from(other: &QueueFull) -> Self` [src]

Performs the conversion.

### `impl From<&'_ TimeoutError> for Py<TimeoutError>` [src]

#### `fn from(other: &TimeoutError) -> Self` [src]

Performs the conversion.

### `impl From<&'_ gaierror> for Py<gaierror>` [src]

#### `fn from(other: &gaierror) -> Self` [src]

Performs the conversion.

### `impl From<&'_ herror> for Py<herror>` [src]

#### `fn from(other: &herror) -> Self` [src]

Performs the conversion.

### `impl From<&'_ timeout> for Py<timeout>` [src]

#### `fn from(other: &timeout) -> Self` [src]

Performs the conversion.

### `impl<T> From<Py<T>> for PyObject where
T: AsRef<PyAny>,` [src]

#### `fn from(other: Py<T>) -> Self` [src]

Performs the conversion.

### `impl<'a, T> From<PyRef<'a, T>> for Py<T> where
T: PyClass,` [src]

#### `fn from(pyref: PyRef<'a, T>) -> Self` [src]

Performs the conversion.

### `impl<'a, T> From<PyRefMut<'a, T>> for Py<T> where
T: PyClass,` [src]

#### `fn from(pyref: PyRefMut<'a, T>) -> Self` [src]

Performs the conversion.

### `impl<'a, T> FromPyObject<'a> for Py<T> where
T: PyTypeInfo,
&'a T::AsRefTarget: FromPyObject<'a>,
T::AsRefTarget: 'a + AsPyPointer,` [src]

#### `fn extract(ob: &'a PyAny) -> PyResult<Self>` [src]

Extracts `Self` from the source `PyObject`.

### `impl IntoPy<Py<CancelledError>> for &CancelledError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<CancelledError>` [src]

Performs the conversion.

### `impl IntoPy<Py<IncompleteReadError>> for &IncompleteReadError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<IncompleteReadError>` [src]

Performs the conversion.

### `impl IntoPy<Py<InvalidStateError>> for &InvalidStateError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<InvalidStateError>` [src]

Performs the conversion.

### `impl IntoPy<Py<LimitOverrunError>> for &LimitOverrunError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<LimitOverrunError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PanicException>> for &PanicException` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PanicException>` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for Option<T> where
T: IntoPy<PyObject>,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for ()` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<K, V, H> IntoPy<Py<PyAny>> for HashMap<K, V, H> where
K: Hash + Eq + IntoPy<PyObject>,
V: IntoPy<PyObject>,
H: BuildHasher,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<K, V> IntoPy<Py<PyAny>> for BTreeMap<K, V> where
K: Eq + IntoPy<PyObject>,
V: IntoPy<PyObject>,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for f64` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for f32` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 0] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 1] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 2] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 3] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 4] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 5] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for &T where
T: AsPyPointer,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 6] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 7] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 8] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 9] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 10] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 11] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 12] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 13] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 14] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 15] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for PyErr` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 16] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 17] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 18] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 19] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 20] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 21] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 22] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 23] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 24] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 25] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<'a> IntoPy<Py<PyAny>> for &'a PyErr` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 26] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 27] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 28] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 29] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 30] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 31] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for [T; 32] where
T: ToPyObject,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for Vec<T> where
T: IntoPy<PyObject>,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for i8` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for u8` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T> IntoPy<Py<PyAny>> for Py<T>` [src]

#### `fn into_py(self, _py: Python<'_>) -> PyObject` [src]

Converts a `Py` instance to `PyObject`. Consumes `self` without calling `Py_DECREF()`.

### `impl IntoPy<Py<PyAny>> for i16` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for u16` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for i32` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for u32` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for i64` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for isize` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for usize` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for u64` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for i128` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for u128` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T: PyClass> IntoPy<Py<PyAny>> for PyRef<'_, T>` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<K, S> IntoPy<Py<PyAny>> for HashSet<K, S> where
K: IntoPy<PyObject> + Eq + Hash,
S: BuildHasher + Default,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<K> IntoPy<Py<PyAny>> for BTreeSet<K> where
K: IntoPy<PyObject> + Ord,` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<'a> IntoPy<Py<PyAny>> for &'a str` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for char` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for String` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<'a> IntoPy<Py<PyAny>> for &'a String` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (A,)` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (A, B)` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (A, B, C)` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>, D: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (A, B, C, D)` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<T: PyClass> IntoPy<Py<PyAny>> for PyRefMut<'_, T>` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>, D: IntoPy<PyObject>, E: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (A, B, C, D, E)` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>, D: IntoPy<PyObject>, E: IntoPy<PyObject>, F: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (A, B, C, D, E, F)` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>, D: IntoPy<PyObject>, E: IntoPy<PyObject>, F: IntoPy<PyObject>, G: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (A, B, C, D, E, F, G)` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>, D: IntoPy<PyObject>, E: IntoPy<PyObject>, F: IntoPy<PyObject>, G: IntoPy<PyObject>, H: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (A, B, C, D, E, F, G, H)` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>, D: IntoPy<PyObject>, E: IntoPy<PyObject>, F: IntoPy<PyObject>, G: IntoPy<PyObject>, H: IntoPy<PyObject>, I: IntoPy<PyObject>> IntoPy<Py<PyAny>> for (A, B, C, D, E, F, G, H, I)` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAny>> for bool` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl<'a> IntoPy<Py<PyAny>> for &'a [u8]` [src]

#### `fn into_py(self, py: Python<'_>) -> PyObject` [src]

Performs the conversion.

### `impl IntoPy<Py<PyArithmeticError>> for &PyArithmeticError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyArithmeticError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAssertionError>> for &PyAssertionError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyAssertionError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyAttributeError>> for &PyAttributeError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyAttributeError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyBaseException>> for &PyBaseException` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyBaseException>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyBlockingIOError>> for &PyBlockingIOError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyBlockingIOError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyBool>> for &PyBool` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyBool>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyBrokenPipeError>> for &PyBrokenPipeError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyBrokenPipeError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyBufferError>> for &PyBufferError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyBufferError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyByteArray>> for &PyByteArray` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyByteArray>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyBytes>> for &PyBytes` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyBytes>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyCFunction>> for &PyCFunction` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyCFunction>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyChildProcessError>> for &PyChildProcessError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyChildProcessError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyComplex>> for &PyComplex` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyComplex>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyConnectionAbortedError>> for &PyConnectionAbortedError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyConnectionAbortedError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyConnectionError>> for &PyConnectionError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyConnectionError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyConnectionRefusedError>> for &PyConnectionRefusedError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyConnectionRefusedError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyConnectionResetError>> for &PyConnectionResetError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyConnectionResetError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyDate>> for &PyDate` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyDate>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyDateTime>> for &PyDateTime` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyDateTime>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyDelta>> for &PyDelta` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyDelta>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyDict>> for &PyDict` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyDict>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyEOFError>> for &PyEOFError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyEOFError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyEnvironmentError>> for &PyEnvironmentError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyEnvironmentError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyException>> for &PyException` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyException>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyFileExistsError>> for &PyFileExistsError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyFileExistsError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyFileNotFoundError>> for &PyFileNotFoundError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyFileNotFoundError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyFloat>> for &PyFloat` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyFloat>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyFloatingPointError>> for &PyFloatingPointError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyFloatingPointError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyFrozenSet>> for &PyFrozenSet` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyFrozenSet>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyFunction>> for &PyFunction` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyFunction>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyGeneratorExit>> for &PyGeneratorExit` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyGeneratorExit>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyIOError>> for &PyIOError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyIOError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyImportError>> for &PyImportError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyImportError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyIndexError>> for &PyIndexError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyIndexError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyInterruptedError>> for &PyInterruptedError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyInterruptedError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyIsADirectoryError>> for &PyIsADirectoryError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyIsADirectoryError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyIterator>> for &PyIterator` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyIterator>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyKeyError>> for &PyKeyError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyKeyError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyKeyboardInterrupt>> for &PyKeyboardInterrupt` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyKeyboardInterrupt>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyList>> for &PyList` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyList>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyLong>> for &PyLong` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyLong>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyLookupError>> for &PyLookupError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyLookupError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyMemoryError>> for &PyMemoryError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyMemoryError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyModule>> for &PyModule` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyModule>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyModuleNotFoundError>> for &PyModuleNotFoundError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyModuleNotFoundError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyNameError>> for &PyNameError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyNameError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyNotADirectoryError>> for &PyNotADirectoryError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyNotADirectoryError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyNotImplementedError>> for &PyNotImplementedError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyNotImplementedError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyOSError>> for &PyOSError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyOSError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyOverflowError>> for &PyOverflowError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyOverflowError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyPermissionError>> for &PyPermissionError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyPermissionError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyProcessLookupError>> for &PyProcessLookupError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyProcessLookupError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyRecursionError>> for &PyRecursionError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyRecursionError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyReferenceError>> for &PyReferenceError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyReferenceError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyRuntimeError>> for &PyRuntimeError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyRuntimeError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PySequence>> for &PySequence` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PySequence>` [src]

Performs the conversion.

### `impl IntoPy<Py<PySet>> for &PySet` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PySet>` [src]

Performs the conversion.

### `impl IntoPy<Py<PySlice>> for &PySlice` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PySlice>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyStopAsyncIteration>> for &PyStopAsyncIteration` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyStopAsyncIteration>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyStopIteration>> for &PyStopIteration` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyStopIteration>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyString>> for &PyString` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyString>` [src]

Performs the conversion.

### `impl IntoPy<Py<PySyntaxError>> for &PySyntaxError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PySyntaxError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PySystemError>> for &PySystemError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PySystemError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PySystemExit>> for &PySystemExit` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PySystemExit>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyTime>> for &PyTime` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTime>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyTimeoutError>> for &PyTimeoutError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTimeoutError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyTuple>> for ()` [src]

Converts `()` to an empty Python tuple.

#### `fn into_py(self, py: Python<'_>) -> Py<PyTuple>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyTuple>> for &PyTuple` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTuple>` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>, D: IntoPy<PyObject>, E: IntoPy<PyObject>, F: IntoPy<PyObject>, G: IntoPy<PyObject>, H: IntoPy<PyObject>, I: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (A, B, C, D, E, F, G, H, I)` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTuple>` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (A,)` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTuple>` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (A, B)` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTuple>` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (A, B, C)` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTuple>` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>, D: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (A, B, C, D)` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTuple>` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>, D: IntoPy<PyObject>, E: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (A, B, C, D, E)` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTuple>` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>, D: IntoPy<PyObject>, E: IntoPy<PyObject>, F: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (A, B, C, D, E, F)` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTuple>` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>, D: IntoPy<PyObject>, E: IntoPy<PyObject>, F: IntoPy<PyObject>, G: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (A, B, C, D, E, F, G)` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTuple>` [src]

Performs the conversion.

### `impl<A: IntoPy<PyObject>, B: IntoPy<PyObject>, C: IntoPy<PyObject>, D: IntoPy<PyObject>, E: IntoPy<PyObject>, F: IntoPy<PyObject>, G: IntoPy<PyObject>, H: IntoPy<PyObject>> IntoPy<Py<PyTuple>> for (A, B, C, D, E, F, G, H)` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTuple>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyType>> for &PyType` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyType>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyTypeError>> for &PyTypeError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTypeError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyTzInfo>> for &PyTzInfo` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyTzInfo>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyUnboundLocalError>> for &PyUnboundLocalError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyUnboundLocalError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyUnicodeDecodeError>> for &PyUnicodeDecodeError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyUnicodeDecodeError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyUnicodeEncodeError>> for &PyUnicodeEncodeError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyUnicodeEncodeError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyUnicodeError>> for &PyUnicodeError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyUnicodeError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyUnicodeTranslateError>> for &PyUnicodeTranslateError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyUnicodeTranslateError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyValueError>> for &PyValueError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyValueError>` [src]

Performs the conversion.

### `impl IntoPy<Py<PyZeroDivisionError>> for &PyZeroDivisionError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<PyZeroDivisionError>` [src]

Performs the conversion.

### `impl IntoPy<Py<QueueEmpty>> for &QueueEmpty` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<QueueEmpty>` [src]

Performs the conversion.

### `impl IntoPy<Py<QueueFull>> for &QueueFull` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<QueueFull>` [src]

Performs the conversion.

### `impl IntoPy<Py<TimeoutError>> for &TimeoutError` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<TimeoutError>` [src]

Performs the conversion.

### `impl IntoPy<Py<gaierror>> for &gaierror` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<gaierror>` [src]

Performs the conversion.

### `impl IntoPy<Py<herror>> for &herror` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<herror>` [src]

Performs the conversion.

### `impl IntoPy<Py<timeout>> for &timeout` [src]

#### `fn into_py(self, py: Python<'_>) -> Py<timeout>` [src]

Performs the conversion.

### `impl<T> IntoPyPointer for Py<T>` [src]

#### `#[must_use]fn into_ptr(self) -> *mut PyObject` [src]

Gets the underlying FFI pointer, returns a owned pointer.

### `impl<T> PartialEq<Py<T>> for Py<T>` [src]

#### `fn eq(&self, o: &Py<T>) -> bool` [src]

This method tests for `self` and `other` values to be equal, and is used by `==`. Read more

#### `#[must_use]pub fn ne(&self, other: &Rhs) -> bool` 1.0.0 [src]

This method tests for `!=`.

### `impl<T> Send for Py<T>` [src]

### `impl<T> Sync for Py<T>` [src]

### `impl<T> ToPyObject for Py<T>` [src]

#### `fn to_object(&self, py: Python<'_>) -> PyObject` [src]

Converts `Py` instance -> PyObject.

## Auto Trait Implementations

### `impl<T> RefUnwindSafe for Py<T> where
T: RefUnwindSafe,`

### `impl<T> Unpin for Py<T> where
T: Unpin,`

### `impl<T> UnwindSafe for Py<T> where
T: UnwindSafe,`

## Blanket Implementations

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `pub fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

### `impl<T> From<T> for T` [src]

#### `pub fn from(t: T) -> T` [src]

Performs the conversion.

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `pub fn into(self) -> U` [src]

Performs the conversion.

### `impl<T> ToBorrowedObject for T where
T: ToPyObject,` [src]

#### `fn with_borrowed_ptr<F, R>(&self, py: Python<'_>, f: F) -> R where
F: FnOnce(*mut PyObject) -> R,` [src]

Converts self into a Python object and calls the specified closure on the native FFI pointer underlying the Python object. Read more

### `impl<T> ToOwned for T where
T: Clone,` [src]

#### `type Owned = T`

The resulting type after obtaining ownership.

#### `pub fn to_owned(&self) -> T` [src]

Creates owned data from borrowed data, usually by cloning. Read more

#### `pub fn clone_into(&self, target: &mut T)` [src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into`)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

### `impl<T> ToString for T where
T: Display + ?Sized,` [src]

#### `pub default fn to_string(&self) -> String` [src]

Converts the given value to a `String`. Read more

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>` [src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

#### `pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.