Перейти к основному содержимому
🔒 Режим превью. Первые 15 уроков Foundations — бесплатные; этот — Pro. Запусти 7-дневный trial чтобы открыть редактор, AI-подсказки и остальной курс. Нужна карта, отмена в Dashboard в любой момент.Начать 7-дневный trial →
← КурсыSenior Deep-DivesModule 1 · Concurrency internals · RecapExitStack для динамического управления контекстомpredict23 / 161
+100 XP
Задание🌐 shown in EN
📝 **Question:** Predict the exact output. \`res(name)\` is a tiny context manager that prints \`open:\` / \`close:\`. Three resources enter an \`ExitStack\` in order A → B → C. When the \`with\` exits, what order do they close in? 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
Предскажи вывод

Прочти код внимательно

from contextlib import ExitStack, contextmanager


@contextmanager
def res(name):
    print(f"open:{name}")
    try:
        yield name
    finally:
        print(f"close:{name}")


with ExitStack() as stack:
    a = stack.enter_context(res("A"))
    b = stack.enter_context(res("B"))
    c = stack.enter_context(res("C"))
    print(f"use:{a}{b}{c}")

print("done")

Что выведет программа? Напиши здесь: