regex - What is the type of a compiled regular expression to be defined explicitly in Python 3.6? -


this question has answer here:

i writing function deal pre-compiled regular expressions. how define explicitly? e.g.

def use_regular_expression(regular_expression: ???):     pass 

what write in place of "???" accept re.compile outputs given valid regular expression string?

print(type(re.compile(''))) says _sre.sre_pattern , pycharm ide suggests it's re.__regex neither seems work no matter of obvious ways try import , specify them.

thanks whoever has marked question duplicate of this one (i've failed find myself unfortunately) have found correct (i.e. looking for) answer written @flying-sheep, let me cite here may happen stumble upon instance of question:

it's typing.re.pattern.

e.g.

from typing.re import pattern  my_re = re.compile('foo') assert isinstance(my_re, pattern) 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -