@djangoproject · Post #332 · 05.05.2017 г., 19:16
https://dbader.org/blog/queues-in-python How to implement a FIFO #queue data structure in Python using only built-in data types and classes from the standard library.
Hashtags
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #65 · 8 апр.
Небольшой трик с регулярными выражениями который редко вижу в чужом коде. Допустим, вам нужно распарсить простой текст и вытащить оттуда пары имя+телефон. Вернуть всё это надо в виде списка словарей. Возьмем очень простой пример текста. >>> text = ''' >>> Alex:8999123456 >>> Mike:+799987654 >>> Oleg:+344456789 >>> ''' Соответственно, для выделения нужных элементов будем использовать группы. Получится такой паттерн: (\w+):([\d+]+) Как мы будем формировать словарь из найденных групп? >>> import re >>> results = [] >>> for match in re.finditer(r"(\w+):([\d+]+)", text): >>> results.append({ >>> "name": match.group(1), >>> "phone": match.group(2) >>> }) >>> print(results) [{'name': 'Alex', 'phone': '8999123456'}, ...] Можно немного сократить запись используя zip >>> results = [] >>> for match in re.finditer(r"(\w+):([\d+]+)", text): >>> results.append(dict(zip(['name', 'phone'], match.groups()))) Но есть способ лучше! Это именованные группы в regex. Можно в паттерне указать имя группы и результат сразу забрать в виде словаря. >>> for match in re.finditer(r"(?P<name>\w+):(?P<phone>[\d+]+)", text): >>> results.append(match.groupdict()) То есть всё что я сделал, это добавил в начале группы (внутри сбокочек) такую запись: (?P<group-name>...) Теперь найденная группа имеет имя и можно обратиться к ней как к элементу списка >>> name = match['name'] Либо забрать сразу весь словарь методом groupdict() >>> match.groupdict() #tricks#regex
Пребарај: #queue
@djangoproject · Post #332 · 05.05.2017 г., 19:16
https://dbader.org/blog/queues-in-python How to implement a FIFO #queue data structure in Python using only built-in data types and classes from the standard library.
Hashtags
@djangoproject · Post #455 · 03.10.2017 г., 16:39
https://realpython.com/blog/python/asynchronous-tasks-with-django-and-celery/ Asynchronous Tasks With #Django and #Celery “Celery is an asynchronous task queue/job #queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well.” For this post, we will focus on the scheduling feature to periodically run a job/task.
@djangoproject · Post #585 · 23.03.2018 г., 02:43
https://www.fullstackpython.com/celery.html #Celery is a task #queue implementation for Python web applications used to #asynchronously execute work outside the HTTP request-response cycle.
Hashtags
@voir_yeux · Post #12160 · 19.03.2026 г., 11:59
🇬🇪 Des centaines de Géorgiens font la queue pour entrer dans la cathédrale de la Sainte-Trinité de Tbilissi, où se tient la messe de requiem en l'honneur du patriarche Élie II de Géorgie. #géorgie#queue#cathédrale#patriarche
@djangoproject · Post #119 · 10.08.2016 г., 14:37
18.5.8. Queues Queues: #Queue #PriorityQueue #LifoQueue #asyncio queue #API was designed to be close to classes of the queue module (Queue, PriorityQueue, LifoQueue), but it has no timeout parameter. The asyncio.wait_for() function can be used to cancel a task after a timeout. https://docs.python.org/3/library/asyncio-queue.html