Showing content from http://mail.python.org/pipermail/python-dev/attachments/20160317/8d191be1/attachment.html below:
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#330033">
<div class="moz-cite-prefix">On 3/16/2016 12:59 AM, Serhiy Storchaka
wrote:<br>
</div>
<blockquote cite="mid:ncb3ps$fc8$1@ger.gmane.org" type="cite">On
16.03.16 09:46, Glenn Linderman wrote:
<br>
<blockquote type="cite">On 3/16/2016 12:09 AM, Serhiy Storchaka
wrote:
<br>
<blockquote type="cite">On 16.03.16 08:34, Glenn Linderman
wrote:
<br>
<blockquote type="cite">Â From the PEP 263:
<br>
<br>
<blockquote type="cite">More precisely, the first or second
line must match the regular
<br>
   expression "coding[:=]\s*([-\w.]+)". The first group
of this
<br>
   expression is then interpreted as encoding name. If
the encoding
<br>
   is unknown to Python, an error is raised during
compilation. There
<br>
   must not be any Python statement on the line that
contains the
<br>
   encoding declaration.
<br>
</blockquote>
<br>
Clearly the regular expression would only match the first of
multiple
<br>
cookies on the same line, so the first one should always
win... but
<br>
there should only be one, from the first PEP quote "a magic
comment".
<br>
</blockquote>
<br>
"The first group of this expression" means the first regular
<br>
expression group. Only the part between parenthesis
"([-\w.]+)" is
<br>
interpreted as encoding name, not all expression.
<br>
</blockquote>
<br>
Sure. But there is no mention anywhere in the PEP of more than
one
<br>
being legal: just more than one position for it, EITHER line 1
or line
<br>
2. So while the regular expression mentioned is not anchored, to
allow
<br>
variation in syntax between emacs and vim, "must match the
regular
<br>
expression" doesn't imply "several times", and when searching
for a
<br>
regular expression that might not be anchored, one typically
expects to
<br>
find the first.
<br>
</blockquote>
<br>
Actually "must match the regular expression" is not correct,
because re.match() implies anchoring at the start. I have proposed
more correct regular expression in other branch of this thread.<br>
</blockquote>
<br>
"match" doesn't imply anchoring at the start. "re.match()" does
(and as a result is very confusing to newbies to Python re, that
have used other regexp systems).<br>
</body>
</html>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4