Trait cpython::ObjectProtocol [] [src]

pub trait ObjectProtocol: PythonObject {
    fn hasattr<N>(&self, py: Python, attr_name: N) -> PyResult<bool>
    where
        N: ToPyObject
, { ... } fn getattr<N>(&self, py: Python, attr_name: N) -> PyResult<PyObject>
    where
        N: ToPyObject
, { ... } fn setattr<N, V>(&self, py: Python, attr_name: N, value: V) -> PyResult<()>
    where
        N: ToPyObject,
        V: ToPyObject
, { ... } fn delattr<N>(&self, py: Python, attr_name: N) -> PyResult<()>
    where
        N: ToPyObject
, { ... } fn repr(&self, py: Python) -> PyResult<PyString> { ... } fn str(&self, py: Python) -> PyResult<PyString> { ... } fn is_callable(&self, _py: Python) -> bool { ... } fn call<A>(
        &self,
        py: Python,
        args: A,
        kwargs: Option<&PyDict>
    ) -> PyResult<PyObject>
    where
        A: ToPyObject<ObjectType = PyTuple>
, { ... } fn call_method<A>(
        &self,
        py: Python,
        name: &str,
        args: A,
        kwargs: Option<&PyDict>
    ) -> PyResult<PyObject>
    where
        A: ToPyObject<ObjectType = PyTuple>
, { ... } fn hash(&self, py: Python) -> PyResult<Py_hash_t> { ... } fn is_true(&self, py: Python) -> PyResult<bool> { ... } fn len(&self, py: Python) -> PyResult<usize> { ... } fn get_item<K>(&self, py: Python, key: K) -> PyResult<PyObject>
    where
        K: ToPyObject
, { ... } fn set_item<K, V>(&self, py: Python, key: K, value: V) -> PyResult<()>
    where
        K: ToPyObject,
        V: ToPyObject
, { ... } fn del_item<K>(&self, py: Python, key: K) -> PyResult<()>
    where
        K: ToPyObject
, { ... } fn iter<'p>(&self, py: Python<'p>) -> PyResult<PyIterator<'p>> { ... } }

Trait that contains methods

Provided Methods

Determines whether this object has the given attribute. This is equivalent to the Python expression 'hasattr(self, attr_name)'.

Retrieves an attribute value. This is equivalent to the Python expression 'self.attr_name'.

Sets an attribute value. This is equivalent to the Python expression 'self.attr_name = value'.

Deletes an attribute. This is equivalent to the Python expression 'del self.attr_name'.

Compute the string representation of self. This is equivalent to the Python expression 'repr(self)'.

Compute the string representation of self. This is equivalent to the Python expression 'str(self)'.

Determines whether this object is callable.

Calls the object. This is equivalent to the Python expression: 'self(*args, **kwargs)'

Calls a method on the object. This is equivalent to the Python expression: 'self.name(*args, **kwargs)'

Retrieves the hash code of the object. This is equivalent to the Python expression: 'hash(self)'

Returns whether the object is considered to be true. This is equivalent to the Python expression: 'not not self'

Returns the length of the sequence or mapping. This is equivalent to the Python expression: 'len(self)'

This is equivalent to the Python expression: 'self[key]'

Sets an item value. This is equivalent to the Python expression 'self[key] = value'.

Deletes an item. This is equivalent to the Python expression 'del self[key]'.

Takes an object and returns an iterator for it. This is typically a new iterator but if the argument is an iterator, this returns itself.

Implementors