I was reading re's docs and came across this:
Note that the (?x) flag changes how the expression is parsed. It should be used first in the expression string, or after one or more whitespace characters. If there are non-whitespace characters before the flag, the results are undefined.
Is there a particular reason for this being undefined? It seems kind of un-Pythonic to me and more like C/C++. Would it be possible to instead throw an exception, e.g. ValueError?