Skip to content

Commit 5f77f8c

Browse files
Refactor fn_w_counter return type and remove sys import
1 parent ee7428c commit 5f77f8c

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎Week04/functions_aleyna_gultekin.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import sys
2-
31
custom_power = lambda x=0, /, e=1: x ** e
42

53

@@ -29,8 +27,8 @@ def _make_counter():
2927
calls = {"count": 0}
3028
by_caller = {}
3129

32-
def fn_w_counter() -> tuple[int, dict[str, int]]:
33-
name = sys._getframe(1).f_globals.get("__name__")
30+
def fn_w_counter() -> (int, dict[str, int]):
31+
name = fn_w_counter.__module__
3432
calls["count"] += 1
3533
if name in by_caller:
3634
by_caller[name] += 1

0 commit comments

Comments
 (0)