Func any/generics
This commit is contained in:
29
generics_0_func_any.py
Normal file
29
generics_0_func_any.py
Normal 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()
|
||||
Reference in New Issue
Block a user