Say you only wanted to call a regular expression a single time in you code. As far as I am aware, this means that you then need to do import re
somewhere before your call of a function from re
. Is it possible to combine this with the function call, in-line?
I thought maybe something like this would work
print(import re; re.search(r'<regex>', <string>).group())
but it just threw an error saying invalid syntax at the point of the import. This leads me to believe that the only way to do this is
import re
print(re.search(r'<regex>'), <string>).group())