Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document re.Scanner #106338

Open
JosephSBoyle opened this issue Jul 2, 2023 · 3 comments
Open

Document re.Scanner #106338

JosephSBoyle opened this issue Jul 2, 2023 · 3 comments
Labels
docs Documentation in the Doc dir topic-regex

Comments

@JosephSBoyle
Copy link
Contributor

JosephSBoyle commented Jul 2, 2023

Documentation

re.Scanner is currently marked as "experimental" but was added to the standard library 24 years ago[0].
People seem to think this is an interesting feature[1][2] and a github code search for re.Scanner( gives >500 hits[3],
suggesting people have found practical uses for the class.

Proposal

I suggest we add a few lines to the docs describing what it is and perhaps a short docstring with an example.

Some previously collated discussions:
#91308 (comment)

[0].

# experimental stuff (see python-dev discussions for details)

[1]. https://news.ycombinator.com/item?id=36517749
[2]. https://www.reddit.com/r/ProgrammerTIL/comments/4tpt03/python_til_about_rescanner_which_is_useful_for/
[3]. https://github.com/search?q=re.Scanner%28+language%3APython&type=code

@JosephSBoyle JosephSBoyle added the docs Documentation in the Doc dir label Jul 2, 2023
@AlexWaygood
Copy link
Member

@vstinner put together a list of places where this has previously been discussed here: #91308 (comment)

Cc. @serhiy-storchaka as well, for interest

@rhettinger
Copy link
Contributor

I believe that Scanner was intentionally left undocumented and only left in because someone might have found it and relied on it. The tool was deemed to be a dead end.

@serhiy-storchaka
Copy link
Member

One of problems is that it may conflict with the name of internal class _sre.SRE_Scanner if we make it public like we did with _sre.SRE_Pattern and _sre.SRE_Match (now exposed as re.Pattern and re.Match for documentation purposes). _sre.SRE_Scanner is used in implementation of re.Pattern.finditer(), but it also the type of the result of undocumented re.Pattern.scanner(). If we decide to document re.Pattern.scanner(), we will have a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir topic-regex
Projects
None yet
Development

No branches or pull requests

4 participants