Skip to content

Commit

Permalink
Regex, Type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
gto76 committed Mar 12, 2024
1 parent 794a359 commit 9b5d44c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ import re
<iter> = re.finditer(r'<regex>', text) # Returns all occurrences as Match objects.
```

* **Raw string literals do not interpret escape sequences, thus enabling us to use regex-specific escape sequences that cause SyntaxWarning in normal string literals.**
* **Raw string literals do not interpret escape sequences, thus enabling us to use regex-specific escape sequences that cause SyntaxWarning in normal string literals (since 3.12).**
* **Argument 'new' of re.sub() can be a function that accepts a Match object and returns a str.**
* **Argument `'flags=re.IGNORECASE'` can be used with all functions.**
* **Argument `'flags=re.MULTILINE'` makes `'^'` and `'$'` match the start/end of each line.**
Expand Down Expand Up @@ -1026,9 +1026,9 @@ class C(A, B): pass
```python
from collections import abc

<name>: <type> [| ...] [= <obj>]
<name>: list/set/abc.Iterable/abc.Sequence[<type>] [= <obj>]
<name>: dict/tuple[<type>, ...] [= <obj>]
<name>: <type> [| ...] [= <obj>] # `|` since 3.10.
<name>: list/set/abc.Iterable/abc.Sequence[<type>] [= <obj>] # Since 3.9.
<name>: dict/tuple[<type>, ...] [= <obj>] # Since 3.9.
```

### Dataclass
Expand Down
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@


<ul>
<li><strong>Raw string literals do not interpret escape sequences, thus enabling us to use regex-specific escape sequences that cause SyntaxWarning in normal string literals.</strong></li>
<li><strong>Raw string literals do not interpret escape sequences, thus enabling us to use regex-specific escape sequences that cause SyntaxWarning in normal string literals (since 3.12).</strong></li>
<li><strong>Argument 'new' of re.sub() can be a function that accepts a Match object and returns a str.</strong></li>
<li><strong>Argument <code class="python hljs"><span class="hljs-string">'flags=re.IGNORECASE'</span></code> can be used with all functions.</strong></li>
<li><strong>Argument <code class="python hljs"><span class="hljs-string">'flags=re.MULTILINE'</span></code> makes <code class="python hljs"><span class="hljs-string">'^'</span></code> and <code class="python hljs"><span class="hljs-string">'$'</span></code> match the start/end of each line.</strong></li>
Expand Down Expand Up @@ -864,9 +864,9 @@
<li><strong>Hints are used by type checkers like <a href="https://pypi.org/project/mypy/">mypy</a>, data validation libraries such as <a href="https://pypi.org/project/pydantic/">Pydantic</a> and lately also by <a href="https://pypi.org/project/Cython/">Cython</a> compiler. However, they are not enforced by CPython interpreter.</strong></li>
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> abc

&lt;name&gt;: &lt;type&gt; [| ...] [= &lt;obj&gt;]
&lt;name&gt;: list/set/abc.Iterable/abc.Sequence[&lt;type&gt;] [= &lt;obj&gt;]
&lt;name&gt;: dict/tuple[&lt;type&gt;, ...] [= &lt;obj&gt;]
&lt;name&gt;: &lt;type&gt; [| ...] [= &lt;obj&gt;] <span class="hljs-comment"># `|` since 3.10.</span>
&lt;name&gt;: list/set/abc.Iterable/abc.Sequence[&lt;type&gt;] [= &lt;obj&gt;] <span class="hljs-comment"># Since 3.9.</span>
&lt;name&gt;: dict/tuple[&lt;type&gt;, ...] [= &lt;obj&gt;] <span class="hljs-comment"># Since 3.9.</span>
</code></pre></div>


Expand Down

0 comments on commit 9b5d44c

Please sign in to comment.