3 ms·Or even, from Python 3.8: with (ctx_mgr := foo() if bar else nullcontext()): ...by BerislavLopac 6y agoOr even, from Python 3.8: with (ctx_mgr := foo() if bar else nullcontext()): ...