mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
lists --> tuples in plural*.py examples and accompanying text
This commit is contained in:
+7
-7
@@ -12,15 +12,15 @@ def build_match_and_apply_functions(pattern, search, replace):
|
||||
return re.search(pattern, word)
|
||||
def apply_rule(word):
|
||||
return re.sub(search, replace, word)
|
||||
return [matches_rule, apply_rule]
|
||||
return (matches_rule, apply_rule)
|
||||
|
||||
patterns = \
|
||||
[
|
||||
['[sxz]$', '$', 'es'],
|
||||
['[^aeioudgkprt]h$', '$', 'es'],
|
||||
['(qu|[^aeiou])y$', 'y$', 'ies'],
|
||||
['$', '$', 's']
|
||||
]
|
||||
(
|
||||
('[sxz]$', '$', 'es'),
|
||||
('[^aeioudgkprt]h$', '$', 'es'),
|
||||
('(qu|[^aeiou])y$', 'y$', 'ies'),
|
||||
('$', '$', 's')
|
||||
)
|
||||
rules = [build_match_and_apply_functions(pattern, search, replace)
|
||||
for (pattern, search, replace) in patterns]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user