Pattern

class PlasmaCalcs.quantities.quantity_tools.Pattern(pattern)

Bases: object

stores re.Pattern and represents it nicely. Use self.pattern to get re.Pattern object.

Use self.str to get str object.
Intended to be used in an immutable way; don’t change pattern or str after creating.
pattern: str or re.Pattern object
will be compiled to re.Pattern object if str.

Methods

__eq__(other)

return whether self and other are equal.

__hash__()

return hash for self: hash((type(self), self.str))

fullmatch(s, *args_fullmatch, **kw_fullmatch)

returns self.pattern.fullmatch(s, *args, **kw).

match(s, *args_match, **kw_match)

returns self.pattern.match(s, *args, **kw).

__eq__(other)

return whether self and other are equal.

equal if both are Pattern objects with the same str.
[TODO] also allow pattern == s if isinstance(s,str) and s == pattern.str?
__hash__()

return hash for self: hash((type(self), self.str))

fullmatch(s, *args_fullmatch, **kw_fullmatch)

returns self.pattern.fullmatch(s, *args, **kw). Equivalent to re.fullmatch(self.pattern, s, …).

match(s, *args_match, **kw_match)

returns self.pattern.match(s, *args, **kw). Equivalent to re.match(self.pattern, s, …).