newbie how do I interpret this?

Discussion in 'Python' started by bobueland@yahoo.com, Nov 12, 2005.

  1. Guest

    Here's a small session

    >>> 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
    , Nov 12, 2005
    #1
    1. Advertising

  2. wrote:

    > >>> 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>
    Fredrik Lundh, Nov 12, 2005
    #2
    1. Advertising

  3. Mike Meyer Guest

    writes:

    > Here's a small session
    >
    >>>> 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


    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 <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
    Mike Meyer, Nov 12, 2005
    #3
  4. Guest

    Thanks for the reply

    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
    , Nov 12, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aliki
    Replies:
    3
    Views:
    749
    LostAtC
    Sep 24, 2004
  2. James Hunt
    Replies:
    0
    Views:
    447
    James Hunt
    May 19, 2004
  3. Seetha J
    Replies:
    1
    Views:
    3,446
    Robbe Morris [C# MVP]
    May 17, 2005
  4. yzzzzz
    Replies:
    0
    Views:
    851
    yzzzzz
    Jan 7, 2005
  5. myk
    Replies:
    3
    Views:
    482
    Joe Wright
    Feb 22, 2005
Loading...

Share This Page