Skip to content

Commit d3f58bb

Browse files
Update functions_hilmican_karadag.py
1 parent 0d89bba commit d3f58bb

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎Week04/functions_hilmican_karadag.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import inspect
2-
31
# x is positional-only (default 0), e is positional-or-keyword (default 1)
42
custom_power = lambda x=0, /, e=1: x**e
53

@@ -39,9 +37,8 @@ def fn_w_counter() -> (int, dict[str, int]):
3937
:rtype: tuple[int, dict[str, int]]
4038
"""
4139
global _total_calls
42-
caller = inspect.currentframe().f_back.f_globals["__name__"]
4340
_total_calls += 1
44-
_calls_by_caller[caller] = _calls_by_caller.get(caller, 0) + 1
41+
_calls_by_caller[__name__] = _calls_by_caller.get(__name__, 0) + 1
4542
return _total_calls, dict(_calls_by_caller)
4643

4744

@@ -60,3 +57,4 @@ def fn_w_counter() -> (int, dict[str, int]):
6057
for i in range(10):
6158
fn_w_counter()
6259
assert fn_w_counter() == (11, {"__main__": 11})
60+
print("All examples pass.")

0 commit comments

Comments
 (0)