Giampaolo Rodola' <g.rod...@gmail.com> added the comment:

I'm with Antoine. Why not just do this in the context function itself?
I think it's more explicit and easier than reading the doc to figure out what 
nullcontext is supposed to do:


from contextlib import contextmanager

CONDITION = False

@contextmanager
def transaction():
    if not CONDITION:
        yield None
    else:
        yield ...

with transaction() as x:
    ...

----------
nosy: +giampaolo.rodola

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10049>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to