[Python-ideas] Ignorable whitespaces in the re.VERBOSE mode

Stephen J. Turnbull turnbull.stephen.fw at u.tsukuba.ac.jp
Mon Nov 20 03:13:48 EST 2017


If we *do* seriously consider adding those characters as ignorable in
re.VERBOSE, that's because somebody is using them in text a lot, and
it slips into their coding.  Given frequent use, we should consider
how a lot more whitespace characters can be conveniently searched
individually and readably, because whitespace characters are the
ultimate confusables.  This may be a no-op, given the \N and \u
notations, but \u is pretty opaque and \N leads to character-per-line
regexes. ;-)

Otherwise I'm with Paul, who writes:

 > My instinct is not to worry about it unless someone has actually hit
 > the issue in practice and raised a bug.

After the tabs vs. spaces fiasco, I lean steeply to the right for code
-- including embedded languages like regexes.  *We* say what is
allowed there, and *you* can find an editor that does it our way.

The point of re.VERBOSE is to allow writing regexes the way we write
Python code, formatting to emphasize structure and improve
readability.  I don't see why we would want to allow more than we
already do, given that any fancy whitespace formatting for "literate
programming" will be done by the code formatting engine of the
document preparation system anyway.

More information about the Python-ideas mailing list