
I was surprised to see the following Python code works fine
with urllib.request.urlopen(some_url, timeout=1) as response:
info = response.read().decode("utf-8")
match = re.search(r"some-count: ([0-9]+)", info)
And it turns out the with statement does not create a scope in Python.