생각 운동 : 정규식 패턴 또는 정확하게 일치하는 문자열을 취하는 파이썬 함수를 작성하는 "최고"방법은 무엇입니까 :결정
import re
strings = [...]
def do_search(matcher):
"""
Returns strings matching matcher, which can be either a string
(for exact match) or a compiled regular expression object
(for more complex matches).
"""
if not is_a_regex_pattern(matcher):
matcher = re.compile('%s$' % re.escape(matcher))
for s in strings:
if matcher.match(s):
yield s
을 따라서는, 아이디어 is_a_regex_pattern()
구현을 위해?