From d0465110faf08ef3420e3cdd3fee5e2ec77868d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20G=C3=B6r?= Date: Sat, 5 Aug 2023 16:50:18 +0300 Subject: [PATCH] =?UTF-8?q?Dekorat=C3=B6rler=20yaln=C4=B1zca=20global=20fo?= =?UTF-8?q?nksiyonlara=20de=C4=9Fil=20bir=20s=C4=B1n=C4=B1f=C4=B1n=20metot?= =?UTF-8?q?lar=C4=B1na=20da=20uygulanabilmektedir.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python-temel/sinifin.metotlarina.dekorator.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 python-temel/sinifin.metotlarina.dekorator.py diff --git a/python-temel/sinifin.metotlarina.dekorator.py b/python-temel/sinifin.metotlarina.dekorator.py new file mode 100644 index 0000000..092cc28 --- /dev/null +++ b/python-temel/sinifin.metotlarina.dekorator.py @@ -0,0 +1,18 @@ +def bar(f): + def g(*args, **kwargs): + print('araya girilen kod') + f(*args, **kwargs) + + return g + +class Sample: + def __init__(self, a): + self.a = a + + @bar + def foo(self): + print(self.a) + # foo = bar(foo) + +s = Sample(10) +s.foo # Sample.foo(s, 10)