Why is there no __enter__ and __exit__ magic methods in Zeroconf class?
Adding them would allow using it with with statement, simplifying it's usage.
This code from example:
zeroconf = Zeroconf()
try:
print(zeroconf.get_service_info(TYPE, NAME + '.' + TYPE))
finally:
zeroconf.close()
would become just:
with Zeroconf() as zeroconf:
print(zeroconf.get_service_info(TYPE, NAME + '.' + TYPE))
P.S. Yes, i know that i can do that with contextlib.closing()
Why is there no
__enter__and__exit__magic methods inZeroconfclass?Adding them would allow using it with
withstatement, simplifying it's usage.This code from example:
would become just:
P.S. Yes, i know that i can do that with
contextlib.closing()