Struct cpython::PySequence [−][src]
pub struct PySequence(_);
Represents a reference to a python object supporting the sequence protocol.
Methods
impl PySequence
[src]
impl PySequence
pub fn len(&self, py: Python) -> PyResult<isize>
[src]
pub fn len(&self, py: Python) -> PyResult<isize>
Returns the number of objects in sequence. This is equivalent to Python len()
.
pub fn concat(&self, py: Python, other: &PySequence) -> PyResult<PyObject>
[src]
pub fn concat(&self, py: Python, other: &PySequence) -> PyResult<PyObject>
Return the concatenation of o1 and o2. Equivalent to python o1 + o2
pub fn repeat(&self, py: Python, count: isize) -> PyResult<PyObject>
[src]
pub fn repeat(&self, py: Python, count: isize) -> PyResult<PyObject>
Return the result of repeating sequence object o count times.
Equivalent to python o * count
NB: Python accepts negative counts; it returns an empty Sequence.
pub fn in_place_concat(
&self,
py: Python,
other: &PySequence
) -> PyResult<PyObject>
[src]
pub fn in_place_concat(
&self,
py: Python,
other: &PySequence
) -> PyResult<PyObject>
Return the concatenation of o1 and o2 on success. Equivalent to python o1 += o2
pub fn in_place_repeat(&self, py: Python, count: isize) -> PyResult<PyObject>
[src]
pub fn in_place_repeat(&self, py: Python, count: isize) -> PyResult<PyObject>
Return the result of repeating sequence object o count times.
Equivalent to python o *= count
NB: Python accepts negative counts; it empties the Sequence.
pub fn get_item(&self, py: Python, index: isize) -> PyResult<PyObject>
[src]
pub fn get_item(&self, py: Python, index: isize) -> PyResult<PyObject>
Return the ith element of the Sequence. Equivalent to python o[index]
pub fn get_slice(
&self,
py: Python,
begin: isize,
end: isize
) -> PyResult<PyObject>
[src]
pub fn get_slice(
&self,
py: Python,
begin: isize,
end: isize
) -> PyResult<PyObject>
Return the slice of sequence object o between begin and end.
This is the equivalent of the Python expression o[begin:end]
pub fn set_item(&self, py: Python, i: isize, v: &PyObject) -> PyResult<()>
[src]
pub fn set_item(&self, py: Python, i: isize, v: &PyObject) -> PyResult<()>
Assign object v to the ith element of o.
Equivalent to Python statement o[i] = v
pub fn del_item(&self, py: Python, i: isize) -> PyResult<()>
[src]
pub fn del_item(&self, py: Python, i: isize) -> PyResult<()>
Delete the ith element of object o.
Python statement del o[i]
pub fn set_slice(
&self,
py: Python,
i1: isize,
i2: isize,
v: &PyObject
) -> PyResult<()>
[src]
pub fn set_slice(
&self,
py: Python,
i1: isize,
i2: isize,
v: &PyObject
) -> PyResult<()>
Assign the sequence object v to the slice in sequence object o from i1 to i2.
This is the equivalent of the Python statement o[i1:i2] = v
pub fn del_slice(&self, py: Python, i1: isize, i2: isize) -> PyResult<()>
[src]
pub fn del_slice(&self, py: Python, i1: isize, i2: isize) -> PyResult<()>
Delete the slice in sequence object o from i1 to i2.
equivalent of the Python statement del o[i1:i2]
pub fn count<V>(&self, py: Python, value: V) -> PyResult<usize> where
V: ToPyObject,
[src]
pub fn count<V>(&self, py: Python, value: V) -> PyResult<usize> where
V: ToPyObject,
Return the number of occurrences of value in o, that is, return the number of keys for
which o[key] == value
pub fn contains<V>(&self, py: Python, value: V) -> PyResult<bool> where
V: ToPyObject,
[src]
pub fn contains<V>(&self, py: Python, value: V) -> PyResult<bool> where
V: ToPyObject,
Determine if o contains value. this is equivalent to the Python expression value in o
pub fn index<V>(&self, py: Python, value: V) -> PyResult<usize> where
V: ToPyObject,
[src]
pub fn index<V>(&self, py: Python, value: V) -> PyResult<usize> where
V: ToPyObject,
Return the first index i for which o[i] == value.
This is equivalent to the Python expression o.index(value)
pub fn list(&self, py: Python) -> PyResult<PyList>
[src]
pub fn list(&self, py: Python) -> PyResult<PyList>
Return a fresh list based on the Sequence.
pub fn tuple(&self, py: Python) -> PyResult<PyTuple>
[src]
pub fn tuple(&self, py: Python) -> PyResult<PyTuple>
Return a fresh tuple based on the Sequence.
pub fn iter<'p>(&self, py: Python<'p>) -> PyResult<PyIterator<'p>>
[src]
pub fn iter<'p>(&self, py: Python<'p>) -> PyResult<PyIterator<'p>>
Trait Implementations
impl ToPyObject for PySequence
[src]
impl ToPyObject for PySequence
Identity conversion: allows using existing PyObject
instances where
T: ToPyObject
is expected.
type ObjectType = PySequence
fn to_py_object(&self, py: Python) -> PySequence
[src]
fn to_py_object(&self, py: Python) -> PySequence
Converts self into a Python object.
fn into_py_object(self, _py: Python) -> PySequence
[src]
fn into_py_object(self, _py: Python) -> PySequence
Converts self into a Python object. Read more
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R,
[src]
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R,
Converts self into a Python object and calls the specified closure on the native FFI pointer underlying the Python object. Read more
impl<'source> FromPyObject<'source> for PySequence
[src]
impl<'source> FromPyObject<'source> for PySequence
fn extract(py: Python, obj: &'source PyObject) -> PyResult<PySequence>
[src]
fn extract(py: Python, obj: &'source PyObject) -> PyResult<PySequence>
Extracts Self
from the source PyObject
.
impl<'source> FromPyObject<'source> for &'source PySequence
[src]
impl<'source> FromPyObject<'source> for &'source PySequence
fn extract(py: Python, obj: &'source PyObject) -> PyResult<&'source PySequence>
[src]
fn extract(py: Python, obj: &'source PyObject) -> PyResult<&'source PySequence>
Extracts Self
from the source PyObject
.
impl PythonObject for PySequence
[src]
impl PythonObject for PySequence
fn as_object(&self) -> &PyObject
[src]
fn as_object(&self) -> &PyObject
Casts the Python object to PyObject.
fn into_object(self) -> PyObject
[src]
fn into_object(self) -> PyObject
Casts the Python object to PyObject.
unsafe fn unchecked_downcast_from(obj: PyObject) -> Self
[src]
unsafe fn unchecked_downcast_from(obj: PyObject) -> Self
Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
ⓘImportant traits for &'a mut Runsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self
[src]
unsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self
Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
impl PythonObjectWithCheckedDowncast for PySequence
[src]
impl PythonObjectWithCheckedDowncast for PySequence
fn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PySequence, PythonObjectDowncastError<'p>>
[src]
fn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PySequence, PythonObjectDowncastError<'p>>
Cast from PyObject to a concrete Python object type.
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PySequence, PythonObjectDowncastError<'p>>
[src]
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PySequence, PythonObjectDowncastError<'p>>
Cast from PyObject to a concrete Python object type.
Auto Trait Implementations
impl Send for PySequence
impl Send for PySequence
impl Sync for PySequence
impl Sync for PySequence