From 86a40c5d91474e0815144121d3dca518bab72492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20G=C3=B6r?= Date: Tue, 22 Aug 2023 15:30:55 +0300 Subject: [PATCH] with deyimi 1 --- python-temel/with.deyimi.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 python-temel/with.deyimi.py diff --git a/python-temel/with.deyimi.py b/python-temel/with.deyimi.py new file mode 100644 index 0000000..3af128b --- /dev/null +++ b/python-temel/with.deyimi.py @@ -0,0 +1,16 @@ +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...')