On Thu, Feb 8, 2018 at 4:15 AM, Peng Yu <pengyu...@gmail.com> wrote: > Hi, > > I see _sre.SRE_Match is returned by re.match. But I don't find where > it is defined. Does anybody know how to get its help page within > python command line? Thanks. > >>>> import re >>>> m = re.match('a', 'abc') >>>> print type(m) > <type '_sre.SRE_Match'> >>>> _sre.SRE_Match > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > NameError: name '_sre' is not defined >
You can "import _sre" if you want access to that module, but the leading underscore is a strong indication that this isn't something you should be looking at - it's an implementation detail. Python 3 makes this type public: >>> import re >>> re.match('a', 'abc') <re.Match object; span=(0, 1), match='a'> >>> re.Match <class 're.Match'> So if you truly need to examine this type, I suggest switching to a newer Python. ChrisA -- https://mail.python.org/mailman/listinfo/python-list