How to access the help page of SRE_Pattern?
On Mon, 05 Mar 2018 18:13:59 -0600, Peng Yu wrote:
>>>> import re
> I can use the above command to access SRE_Pattern. But this involves the
> creation of an object of the class.
If you're using help() interactively, the cost of creating the instance
is about a millionth of the cost of actually reading the help text.
should be perfectly acceptable, performance-wise, even though it is a
tiny bit longer to write than:
If you really want a reference to the SRE_Pattern class, I'm afraid it is
not public name. It is technically an implementation detail subject to
change without notice. It could change its name, its internal details,
its location, so long as it still offers the public regular expression
I believe that SRE_Pattern is a built-in class, literally built into the
The best way to get access to it is to do this once, at the beginning of
SRE_Pattern = type(re.compile(''))
If you are doing this in the interactive interpreter, you might want to
include that in your Python startup file.