#!/usr/bin/env python3
from contextlib import ExitStack
from functools import partial
print("counting")
with ExitStack() as stack:
for i in range(10):
a = i
stack.callback(partial(print, a, i))
x = 42
a = x
print("done")
IyEvdXNyL2Jpbi9lbnYgcHl0aG9uMwpmcm9tIGNvbnRleHRsaWIgaW1wb3J0IEV4aXRTdGFjawpmcm9tIGZ1bmN0b29scyBpbXBvcnQgcGFydGlhbAoKcHJpbnQoImNvdW50aW5nIikKd2l0aCBFeGl0U3RhY2soKSBhcyBzdGFjazoKICAgIGZvciBpIGluIHJhbmdlKDEwKToKICAgICAgICBhID0gaQogICAgICAgIHN0YWNrLmNhbGxiYWNrKHBhcnRpYWwocHJpbnQsIGEsIGkpKQoKICAgIHggPSA0MgogICAgYSA9IHgKICAgIHByaW50KCJkb25lIik=