TGViewer
Python tests Python tests @python_testit · 6.9K subscribers
Post #1164 1.23K
Что выведет этот код при запуске на Python 3.10+ (например, 3.11)?


📌 Подсказка: Подумайте о порядке проверок, о том, какие атрибуты попадают в others, и об использовании __match_args__.

Ответ:

Automatic mode
Mode manual, other keys: ['threshold', 'debug']
Low threshold 0
Краткое пояснение:

Для первого объекта (mode="auto", threshold=10) срабатывает первый case Config(mode="auto") → Automatic mode.

Для второго (mode="manual", threshold=5, debug=True) первый не совпадает, второй с threshold<5 не проходит (5 < 5 → False), зато третий case Config(mode=mode, **others) — биндинг mode='manual', остальные ключи (threshold и debug) попадают в others → Mode manual, other keys: ['threshold', 'debug'].

Для третьего (threshold=0) первый и третий не подходят (нет mode), а второй — case Config(threshold=threshold) if threshold<5 — срабатывает (0<5) → Low threshold 0.
More from @python_testit
  1. Sep 6, 2026🐍 Python считает эти даты равными. Хотя между ними целый час В ночь перевода часов время…
  2. Aug 14, 2026Post #1269
  3. Aug 14, 2026photo post
  4. Aug 14, 2026🔥 Python + AI без игрушечных демок. Курс для тех, кто хочет собирать рабочие системы. Ste…
  5. Jul 22, 2026Post #1266
  6. Jul 22, 2026photo post
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →