from contextlib import contextmanager


@contextmanager
def my_context_manager():
    print("begin")
    yield "middle"
    print("end")


with my_context_manager() as f:
    print(f)


# from typing import Iterator

# # deeply_nested = [[[1, 2, 3], [4, 5]], [[6, 7], [8, 9]]]


# # def flatten(deeply_nested: list) -> Iterator[int]:
# #     for a in deeply_nested:
# #         for b in a:
# #             for c in b:
# #                 yield c
# #                 print("here")


# # for inner in flatten(deeply_nested):
# #     print(inner)


# def infinite(private_key):
#     while True:
#         yield from private_key


# for private_key_char, plaintext_char in zip(infinite("hello"), "my plaintext"):
#     print("combine", private_key_char, plaintext_char)
