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
| class List: | |
| def __init__(self, items): | |
| super().__init__() | |
| self._items = items | |
| def __call__(self, function): | |
| self._items = map(function, self) | |
| return self | |
| def __iter__(self): |
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
| import logging | |
| import random | |
| from dataclasses import dataclass, field | |
| from decimal import Decimal | |
| from typing import Callable, Iterable, List, Union | |
| _logger = logging.getLogger(__name__) | |
| MENU = [ |
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
| import enum | |
| class BinaryNode: | |
| def __init__(self, data, parent=None): | |
| self.data = data | |
| self._parent = parent | |
| self._left = None | |
| self._right = None |
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
| import logging | |
| import threading | |
| def worker(event: threading.Event, /, *, sleep: float = 1): | |
| while not event.is_set(): | |
| logging.debug("worker thread checking in") | |
| event.wait(sleep) | |
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 timeit import Timer | |
| def concatenation(sequence): | |
| result = '' | |
| for char in sequence: | |
| result += char | |
| return result | |
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
| import sys | |
| from functools import lru_cache | |
| class Executor(dict): | |
| def register(self, func): | |
| if func.__name__ in self: | |
| raise NameError(f'{func.__name__} already register') | |
| self[func.__name__] = func | |
| return func |
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 __future__ import annotations | |
| import functools | |
| import inspect | |
| import warnings | |
| from typing import Callable, Type, Union | |
| __all__ = ('DEFAULT_STACK_LEVEL', 'deprecated', 'pending_deprecation', 'warn') | |
| DEFAULT_STACK_LEVEL = 3 |
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 collections import OrderedDict | |
| empty = object() | |
| class Item: | |
| """ | |
| Descriptor | |
| Usage: | |
| >>> class SomethingType: |
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 urllib.parse import ( | |
| parse_qsl, | |
| urlencode, | |
| urlparse, | |
| urlunparse, | |
| ) | |
| def inject_query_parameters(url: str, params: dict) -> str: | |
| parts = urlparse(url) |
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
| """ | |
| My solution | |
| See https://t.me/aiohttp_ru/3955 | |
| """ | |
| import asyncio | |
| import json | |
| import aiohttp | |
| from asgiref.sync import sync_to_async |