On Wednesday, February 7, 2018 at 5:20:42 PM UTC, Chris Angelico wrote: > On Thu, Feb 8, 2018 at 4:15 AM, Peng Yu 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
I'm confused:- Python 3.6.3 (default, Oct 3 2017, 21:45:48) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> re.match('a', 'abc') <_sre.SRE_Match object; span=(0, 1), match='a'> >>> Perhaps not, https://bugs.python.org/issue30397 so 3.7 only. -- Kindestregards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list