Ob#
- class discopy.cat.Ob(name)[source]#
Bases:
object
Defines an object in a free category, only distinguished by its name.
- Parameters:
name (any) – Name of the object.
Note
When printing an object, we only print its name.
>>> x = Ob('x') >>> print(x) x
Objects are equal only to objects with equal names.
>>> x = Ob('x') >>> assert x == Ob('x') and x != 'x' and x != Ob('y')
Objects are hashable whenever their name is.
>>> d = {Ob(['x', 'y']): 42} Traceback (most recent call last): ... TypeError: unhashable type: 'list'
- property name#
The name of an object is immutable, it cannot be empty.
>>> x = Ob('x') >>> x.name 'x' >>> x.name = 'y' Traceback (most recent call last): ... AttributeError: can't set attribute...