<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:09 AM, Serhiy Storchaka
      wrote:<br>
    </div>
    <blockquote cite="mid:ncb0ql$2bs$1@ger.gmane.org" 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
      expression group. Only the part between parenthesis "([-\w.]+)" is
      interpreted as encoding name, not all expression.<br>
    </blockquote>
    <br>
    Sure.  But there is no mention anywhere in the PEP of more than one
    being legal: just more than one position for it, EITHER line 1 or
    line 2. So while the regular expression mentioned is not anchored,
    to allow variation in syntax between emacs and vim, "must match the
    regular expression" doesn't imply "several times", and when
    searching for a regular expression that might not be anchored, one
    typically expects to find the first.<br>
    <br>
    Glenn<br>
  </body>
</html>