New Python regex Doc (was: Python documentation moronicities)

marco marco at reimeika.ca
Wed Apr 20 16:58:33 EDT 2005


Re: http://xahlee.org/perl-python/python_re-write/lib/module-re.html

Bill Mill <bill.mill at gmail.com> writes:

> Alright, I feel like I'm feeding the trolls just by posting in this
> thread. Just so that nobody else has to read the "revised" docs, no it
> doesn't:

I find that Lee's version complements the official docs quite nicely.

> 1) He didn't really change anything besides the intro page and
> deleting the matching vs. searching page and the examples page. He
> also put a couple of <hr> breaks into the doc.

Official doc:

findall(pattern, string[, flags])

    Return a list of all non-overlapping matches of pattern in string. If
    one or more groups are present in the pattern, return a list of groups;
    this will be a list of tuples if the pattern has more than one
    group. Empty matches are included in the result unless they touch the
    beginning of another match. New in version 1.5.2. Changed in version
    2.4: Added the optional flags argument.

Revised doc:

findall(pattern, string[, flags])

    Return a list of all non-overlapping matches of pattern in string. For
    example:

re.findall(r'@+', 'what   @@@do  @@you @think')
# returns ['@@@', '@@', '@']

    If one or more groups are present in the pattern, return a list of
    groups; this will be a list of tuples if the pattern has more than one
    group. For example:

re.findall(r'( +)(@+)', 'what   @@@do  @@you @think')
# returns [('   ', '@@@'), ('  ', '@@'), (' ', '@')]

    Empty matches are included in the result unless they touch the
    beginning of another match. For example:

re.findall(r'\b', 'what   @@@do  @@you @think')
# returns ['', '', '', '', '', '', '', '']

need another example here showing what is meant by "unless they touch the
beginning of another match."


Personally I find the latter much clearer (even in its incomplete state).

> 3) adding "MAY NEED AN EXAMPLE HERE" instead of actually putting one in

Well, you could suggest one to him.

Cheers,

--
marco at reimeika.ca
Gunnm: Broken Angel                      http://amv.reimeika.ca
http://reimeika.ca/                      http://photo.reimeika.ca



More information about the Python-list mailing list