Skip to content

Commit 3150a5b

Browse files
Update functions_fevzi_bagriacik.py
1 parent a6704b8 commit 3150a5b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Week04/functions_fevzi_bagriacik.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import inspect
2+
13
custom_power = lambda x = 0, /, e = 1 : x ** e
24

35
def custom_equation(x = 0, y = 0, /, a = 1, b = 1, *, c = 1):
@@ -14,5 +16,21 @@ def custom_equation(x = 0, y = 0, /, a = 1, b = 1, *, c = 1):
1416

1517
return (x ** a + y ** b) / c
1618

19+
def fn_w_counter() -> (int, dict):
20+
if not hasattr(fn_w_counter, 'total_count'):
21+
fn_w_counter.total_count = 0
22+
fn_w_counter.caller_dict = {}
23+
24+
caller_frame = inspect.currentframe().f_back
25+
caller_name = caller_frame.f_globals['__name__']
26+
27+
fn_w_counter.total_count += 1
28+
29+
if caller_name in fn_w_counter.caller_dict:
30+
fn_w_counter.caller_dict[caller_name] += 1
31+
else:
32+
fn_w_counter.caller_dict[caller_name] = 1
33+
34+
return fn_w_counter.total_count, fn_w_counter.caller_dict
1735

1836

0 commit comments

Comments
 (0)