It would be nice if exact search match opened the page instead of showing results list

First a little background. I use Firefox search keywords to speed up searching. For example if I type “py pathlib” in the addressbar Firefox uses the py keyword to open docs.python.org and put “pathlib” in the search field and then hit enter. I do the same for other sites such as “w python” will do a wikipedia search for python.

For most search engines, show a list of results is fine because there are going to be many matches. However, when I am searching python docs and I provide a search term with an exact match I think it would be nice to just open that page and save me the extra step of selecting one of the search results.

It seems to me that if I search using a specific name such as pathlib I am almost certainly looking for the pathlib documentation and not all the pages with pathlib mentioned. Similarly, if I search for “str.replace” it is almost certain that I want to see the function documentation so that I can check what parameters are accepted.

I am hoping others feel the same way and can help refine the idea so that most searches can go directly to the target page.

Some ideas:

  • if there is an exact match then open to that result
  • if the search term is prefixed by “>” then go to the exact page (first result). This would mean that “> pathlib” would open the pathlib documentation and “pathlib” would open the search results
  • if the search term is prefixed by “*” then go to the search results otherwise go directly to the first result

I am just hoping to start a conversion about ways to make documentation more efficient to work with.

1 Like

A little hack for this is that these search keywords don’t actually need to be for a search bar. They’re just a URL template that you can customize. e.g. the URL for searching the docs is https://docs.python.org/3/search.html?q=%s where %s is the query. If you wanted, you could create a version that will go directly to a stdlib module’s page, just edit the URL to:

https://docs.python.org/3/library/%s.html

Of course if there isn’t a module by that name, you’ll get a 404, which isn’t ideal. But I imagine most of the time you know what you’re looking for.

2 Likes