To overcome Github's search limitations, one can use Chrome's codesearch or the public github dataset available on bigquery (note: it's only a sample from 2012 if I'm not mistaken).
https://cs.chromium.org/search/?q=lang:py+re%5C.findall%5C(.*%5C)%5C%5B0%5C%5D&sq=package:chromium&type=cs returns 5 results while the following query: SELECT COUNT(*) FROM (SELECT c.id id, c.content content, f.repo_name repo_name, f.path path FROM `bigquery-public-data.github_repos.sample_files` f JOIN ( SELECT * FROM `bigquery-public-data.github_repos.sample_contents` ) c ON f.id = c.id WHERE ENDS_WITH(f.path, ".py") AND REGEXP_CONTAINS(c.content, "re\\.findall\\(.*\\)\\[0\\]") ) returns 84 entries. On Thu, Dec 5, 2019 at 6:51 PM Kyle Stanley <aeros...@gmail.com> wrote: > > Serhiy Storchaka wrote: > > We still do not know a use case for findfirst. If the OP would show his > > code and several examples in others code this could be an argument for > > usefulness of this feature. > > I'm not sure about the OP's exact use case, but using GitHub's code search > for .py files that match with "first re.findall" shows a decent amount of > code that uses the format ``re.findall()[0]``. It would be nice if GitHub's > search properly supported symbols and regular expressions, but this > presents a decent number of examples. See > https://github.com/search?l=Python&q=first+re.findall&type=Code. > > I also spent some time looking for a few specific examples, since there > were a number of false positives in the above results. Note that I didn't > look much into the actual purpose of the code or judge it based on quality, > I was just looking for anything that seemed remotely practical and > contained something along the lines of ``re.findall()[0]``. Several of the > links below contain multiple lines where findfirst would likely be a better > alternative, but I only included one permalink per code file. > > > https://github.com/MohamedAl-Hussein/my_projects/blob/15feca5254fe1b2936d39369365867496ce5b2aa/fifa_workspace/fifa_market_analysis/fifa_market_analysis/items.py#L325 > > https://github.com/MohamedAl-Hussein/FIFA/blob/2b1390fe46f94648e5b0bcfd28bc67a3bc43f09d/fifa_data/fifa_data/items.py#L370 > > https://github.com/democracyworks/dog-catcher/blob/9f6200084d4505091399d36ab0d5e3379b04588c/new_jersey.py#L82 > > https://github.com/democracyworks/dog-catcher/blob/9f6200084d4505091399d36ab0d5e3379b04588c/connecticut.py#L182 > > https://github.com/jessyL6/CQUPTHUB-spiders_task1/blob/db73c47c0703ed01eb2a6034c37edd9e18abb2e0/ZhongBiao2/spiders/zhongbiao2.py#L176 > > https://github.com/kerinin/giscrape/blob/d398206ed4a7e48e1ef6afbf37b4f98784cf2442/giscrape/spiders/people_search.py#L26 > > https://github.com/songweifun/parsebook/blob/529a86739208e9dc07abbb31363462e2921f00a0/dao/parseMarc.py#L211 > > I'm sure there are far more examples and perhaps some more "realistic" > ones, I only went through the first few pages of results. > > On Thu, Dec 5, 2019 at 3:08 PM Serhiy Storchaka <storch...@gmail.com> > wrote: > >> 05.12.19 21:07, Guido van Rossum пише: >> > The case for findfirst() becomes stronger! There seem plenty of ways to >> > get this wrong. >> >> I write several functions every day. There are many ways to get this >> wrong. But I do not propose to include all these functions in the >> stdlib. If I want to include even a single function, I try to find >> several examples that would benefit from adding this function in the >> stdlib. If I found less examples than I expected I withdraw my idea. >> >> We still do not know a use case for findfirst. If the OP would show his >> code and several examples in others code this could be an argument for >> usefulness of this feature. >> _______________________________________________ >> 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/YKVXRQAST6B7CRNN7LFBZXWVHH6G42YC/ >> Code of Conduct: http://python.org/psf/codeofconduct/ >> > _______________________________________________ > 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/7P4ZZMIL2ZFJOONUSZPNUBOZTAAEMASY/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Sebastian Kreft
_______________________________________________ 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/3Y4FHNORMERUZCXJS7XX2ZE4O4KIJCKN/ Code of Conduct: http://python.org/psf/codeofconduct/