Mutability Cython Implementation

class sage.structure.mutability.Mutability

Bases: object

is_immutable()

Return True if this object is immutable (can not be changed) and False if it is not.

To make this object immutable use self.set_immutable().

EXAMPLE:

sage: v = Sequence([1,2,3,4/5])
sage: v[0] = 5
sage: v
[5, 2, 3, 4/5]
sage: v.is_immutable()
False
sage: v.set_immutable()
sage: v.is_immutable()
True
is_mutable()
set_immutable()

Make this object immutable, so it can never again be changed.

EXAMPLES:

sage: v = Sequence([1,2,3,4/5])
sage: v[0] = 5
sage: v
[5, 2, 3, 4/5]
sage: v.set_immutable()
sage: v[3] = 7
...
ValueError: object is immutable; please change a copy instead.

Previous topic

Dynamic classes

Next topic

Sequences

This Page