[Python-ideas] Generalized version of contextlib.close
robertomartinezp at gmail.com
Mon Mar 26 04:35:17 EDT 2018
sometimes I need to use contextlib.close but over methods with a different
name, for example stop(), halt(), etc. For those cases I have to write my
own contextlib.close specialized version with a hard-coded method name.
I think adding a "method" argument to contextlib.close can be very useful:
def closing(thing, method="close"):
Or maybe something even more generic:
def calling(fn, *args, **kwargs):
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas