我有一个返回上下文管理器的迭代器。
我想要一个 pythonicwith语句,它模拟多个嵌套语句的行为with,每个嵌套语句对应迭代器返回的每个上下文管理器。
with
有人可能会说,我想要(已弃用的)函数的泛化contextlib.nested。
contextlib.nested
python iterator nested contextmanager
contextmanager ×1
iterator ×1
nested ×1
python ×1