OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Why is `re`'s `Pattern` type generic?

  • Thread starter Thread starter bzm3r
  • Start date Start date
B

bzm3r

Guest
Code:
import re

x = re.compile(r"hello")

In the above code, x is determined to have type re.Pattern[str]. But why is re.Pattern generic, and then specialized to string? What does a re.Pattern[int] represent?
<pre class="lang-py prettyprint-override"><code>import re

x = re.compile(r"hello")
</code></pre>
<p>In the above code, <code>x</code> is determined to have type <code>re.Pattern[str]</code>. But why is <code>re.Pattern</code> generic, and then specialized to string? What does a <code>re.Pattern[int]</code> represent?</p>
 

Latest posts

Top