-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathfunction_almira_keles.py
More file actions
38 lines (22 loc) · 1.06 KB
/
function_almira_keles.py
File metadata and controls
38 lines (22 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from __future__ import annotations
import inspect
from typing import Any, Dict, Tuple
custom_power = lambda x=0, /, e=1: x**e
def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float:
return (x**a + y**b) / c
def fn_w_counter() -> Tuple[int, Dict[str, int]]:
if not hasattr(fn_w_counter, "_total"):
fn_w_counter._total = 0 # type: ignore[attr-defined]
if not hasattr(fn_w_counter, "_by_caller"):
fn_w_counter._by_caller = {} # type: ignore[attr-defined]
frame = inspect.currentframe()
caller_frame = frame.f_back if frame is not None else None
caller_name = "<unknown>"
if caller_frame is not None:
caller_name = str(caller_frame.f_globals.get("__name__", "<unknown>"))
fn_w_counter._total += 1 # type: ignore[attr-defined]
by_caller: Dict[str, int] = fn_w_counter._by_caller # type: ignore[attr-defined]
by_caller[caller_name] = by_caller.get(caller_name, 0) + 1
return int(fn_w_counter._total), dict(by_caller) # type: ignore[attr-defined]
Footer
© 2026 Git