pathex.managing.tag module
- class Tag(name: Optional[Hashable] = None)[source]
Bases:
pathex.expressions.nary_operators.concatenation.Concatenation
A Tag identifies a region, where traces needs to be managed.
A Tag is just a concatenation of two Labels objects, identifying the beginning and the end of the region.
They compare as concatenations:
>>> a = Tag('a') >>> from pathex import Concatenation >>> b = Concatenation(a.enter, a.exit) >>> assert a == b >>> assert hash(a) == hash(b)
However the representation is different to ease debugging:
>>> repr(a) "Tag('a')" >>> repr(b) "Concatenation('a.enter', 'a.exit')"
- classmethod anonym(n: int) Iterator[Tag] [source]
Factory method that gives n tags.
>>> a, b = Tag.anonym(2) >>> assert a.name == id(a) >>> assert b.name == id(b)
The names of the tags are the same as its object ids.
- classmethod named(*names: object) Iterator[Tag] [source]
Factory method that gives named tags.
>>> a, b = Tag.named('a', 'b') >>> assert a.name == 'a' >>> assert b.enter == 'b.enter' >>> assert b.exit == 'b.exit'
- name: Hashable