Func any/generics

This commit is contained in:
Eden Kirin
2023-02-16 20:05:39 +01:00
parent 14ecd6b5b2
commit 0fcfcc0c16
2 changed files with 29 additions and 0 deletions

29
generics_0_func_any.py Normal file
View File

@ -0,0 +1,29 @@
from typing import Any, Dict
def get_item(values: Dict, key: Any) -> Any:
return values[key]
def main():
str_keys: Dict[str, int] = {
"prvi": 1,
"drugi": 2,
"treći": 3,
}
a = get_item(str_keys, "drugi")
print(a)
# int_keys: Dict[int, str] = {
# 1: "prvi",
# 2: "drugi",
# 3: "treći",
# }
# a = get_item(int_keys, 3)
# print(a)
if __name__ == "__main__":
main()