15 lines
260 B
Python
15 lines
260 B
Python
|
|
|
|
class Disposable:
|
|
def __init__(self, dispose):
|
|
self.dispose = dispose
|
|
|
|
def __enter__(self):
|
|
pass
|
|
|
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
if self.dispose:
|
|
self.dispose()
|
|
self.dispose = None
|
|
|