import re re_search = re.search def re_search_list(pattern, list_or_text): if isinstance(list_or_text, str): return re_search(pattern, list_or_text) return [re_search_list(pattern, i) for i in list_or_text]
re.search = re_search_list Bottom line: no need to change the function, you can do it yourself. On Tue, Sep 29, 2020 at 06:19:29AM -0000, Giang Le <giang.lh0...@gmail.com> wrote: > Hi, I would like to have the same function re.search(pattern, input) to keep > main code structure to be the same. The input into the re.search function > will be depended on other previous functions. It is also more dynamic for > users. Thank you. Oleg. -- Oleg Broytman https://phdru.name/ p...@phdru.name Programmers don't die, they just GOSUB without RETURN. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/2ZO7GNTT567EQC3DQD6MEVI62WYMK6X2/ Code of Conduct: http://python.org/psf/codeofconduct/