[Python-ideas] Making (?x) less scary

Serhiy Storchaka storchaka at gmail.com
Fri Feb 12 16:39:45 EST 2016


On 12.02.16 23:12, Ned Batchelder wrote:
> On 2/12/16 11:15 AM, Ryan Gonzalez wrote:
>> 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?
>
> Is there a reason to deal with this case at all? Throwing an exception
> means having to add code to detect the condition and raise the exception.

http://bugs.python.org/issue22493




More information about the Python-ideas mailing list