python-CSD-kursu/python-temel/with.deyimi.py
2023-08-22 15:30:55 +03:00

17 lines
338 B
Python

class Sample:
def __init__(self):
print('__init__ called')
def __enter__(self):
print('__enter__ called')
return self
def __exit__(self, exc_type, exc_value, traceback):
print('__exit__ called')
return False
print('begins...')
with Sample() as s:
print('suite')
print('ends...')