This file contains 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 NamedTuple # >= Python.3.6.0 | |
class Employee(NamedTuple): | |
name: str | |
department: str | |
salary: int | |
is_remote: bool = False # >= Python.3.6.1 | |
bob = Employee(name='Bob', department='IT', salary=10000, is_remote=True) |
This file contains 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
import decimal | |
import functools | |
import typing | |
@functools.total_ordering | |
class Money: | |
def __init__(self, amount: str) -> None: | |
self.amount = decimal.Decimal(amount) |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
</head> | |
<body> | |
{{ person.name }} - {{ person.email }} <- autocompletion works like a charm | |
</body> | |
</html> |
This file contains 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
# ugly | |
def register_user(user_data): | |
... | |
save_user_in_db( | |
email=user_data['email'], | |
first_name=user_data['first_name'], | |
... | |
) | |
This file contains 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 unittest import mock | |
# Approach #1 - hidden dependency | |
def func_1(): | |
pass | |
OlderNewer