>>> import re
>>> p=re.compile('[a-z]+')
>>> m=p.match('abb1a')
>>> dir(m)
['__copy__', '__deepcopy__', 'end', 'expand', 'group', 'groupdict',
'groups', 'span', 'start']
>>> help(m.groups)
Help on built-in function groups:
groups(...)
>>>
My question is. How do I interpret the hiven help info
groups(...)
alt1. Tough luck. There's no help. People are to busy to write
reference manuals.
alt 2. There are no parameters. The only possibility is m.groups()
alt3. Something else
Thanks Bob
> >>> help(m.groups)
> Help on built-in function groups:
>
> groups(...)
>
> >>>
>
> My question is. How do I interpret the hiven help info
> groups(...)
>
> alt1. Tough luck. There's no help. People are to busy to write
> reference manuals.
they're busy writing reference manuals, you mean:
http://docs.python.org/lib/match-objects.html
> alt 2. There are no parameters. The only possibility is m.groups()
in this case, that happens to be the most common way to use
the method.
> alt3. Something else
the words "built-in function" means that the function is im-
plemented in C, and is therefore outside the reach of Python's
introspection mechanisms. In this case, there don't seem to
be any custom docstring associated with this method, so the
above is all help() can tell you at the moment. This may of
course change in future releases.
</F>
alt 3, specifically: No doc string, time to check the reference manual.
<URL: http://docs.python.org/lib/match-objects.html > says:
groups( [default])
Return a tuple containing all the subgroups of the match, from
1 up to however many groups are in the pattern. The default
argument is used for groups that did not participate in the
match; it defaults to None. (Incompatibility note: in the
original Python 1.5 release, if the tuple was one element
long, a string would be returned instead. In later versions
(from 1.5.1 on), a singleton tuple is returned in such cases.)
Since you don't have any groups in your re, groups is always going to
return (). You probably want group().
<mike
--
Mike Meyer <m...@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
I didn't realise the meaning of ""built-in function". Also I thought
that help( ) mirrored the info in reference manual, which it obviously
does not. Thanks again for a good answer and the link.
Bob