Created
October 6, 2019 03:43
-
-
Save lachlan-eagling/ec3e0fef62ff7362644d9ae4e469133a to your computer and use it in GitHub Desktop.
Blog - Type Hints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import List, Dict | |
| from models import Employee | |
| def process_employees(employees): | |
| employee_dict = {} | |
| for employee in employees: | |
| employee_dict[employee.id] = employee | |
| return employee_dict | |
| def process_employees(employees: List[Employee]) -> Dict[int, Employee]: | |
| employee_dict: Dict[int, Employee] = {} | |
| for employee in employees: | |
| employee_dict[employee.id] = employee | |
| return employee_dict |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment