I have been playing around with regular expressions and was trying to subclass the MatchObject that is returned from re.search.
I have had no luck getting access to the MatchObject class.
I assume enter code herethat the actual type of this object is not called “MatchObject”:
>>> re.search ("a", "a")
<_sre.SRE_Match object at 0x100427a58>
However, I am not able get access to this object:
import _sre
dir (_sre)
['CODESIZE', 'MAGIC', '__doc__', '__name__', '__package__', 'compile', 'copyright', 'getcodesize', 'getlower']
>>> dir(_sre.SRE_Match)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SRE_Match'
What am I missing?
It’s not gonna happen 🙂
It’s worth noting that you can always get access to the type of an object by calling
type(obj)though.