Skip to content

Instantly share code, notes, and snippets.

@alexey-goloburdin
Last active October 6, 2022 16:19
Show Gist options
  • Save alexey-goloburdin/0cfbf978eb47201e40d6420fc703f563 to your computer and use it in GitHub Desktop.
Save alexey-goloburdin/0cfbf978eb47201e40d6420fc703f563 to your computer and use it in GitHub Desktop.
from datetime import datetime
from typing import NamedTuple
class Group(NamedTuple):
id: int
name: str
class Client(NamedTuple):
id: int
group: Group
payment_type: int
last_authorized: datetime
def get_client_group_name(client: Client) -> str:
return client.group.name
client = Client(
id=1,
group=Group(id=22, name="Постоянный покупатель"),
payment_type=28,
last_authorized=datetime(2017, 5, 1)
)
print(get_client_group_name(client))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment