On Sat, Feb 13, 2010 at 7:59 AM, Kent Johnson wrote:
> On Fri, Feb 12, 2010 at 11:49 PM, Eduardo Vieira
> wrote:
>> Hello! I was reading the latest version of Mark Pilgrim's "Dive into
>> Python" and am confused with these example about the pluralization
>> rules. See http://diveintopython3.org/e
On Fri, Feb 12, 2010 at 11:49 PM, Eduardo Vieira
wrote:
> Hello! I was reading the latest version of Mark Pilgrim's "Dive into
> Python" and am confused with these example about the pluralization
> rules. See http://diveintopython3.org/examples/plural3.py and
> http://diveintopython3.org/generator
"Eduardo Vieira" wrote
def build_match_and_apply_functions(pattern, search, replace):
def matches_rule(word):
return re.search(pattern, word)
def apply_rule(word):
return re.sub(search, replace, word)
return (matches_rule, apply_rule)
patterns = \
(
('[sxz]$',
Hello! I was reading the latest version of Mark Pilgrim's "Dive into
Python" and am confused with these example about the pluralization
rules. See http://diveintopython3.org/examples/plural3.py and
http://diveintopython3.org/generators.html#a-list-of-patterns
Here is part of the code:
import re
de