Регулярные выражения иногда могут быть просто монструозными. Выглядеть это может крайне запутанно. Сами регэкспы и без того история непростая, а когда это длинный паттерн на несколько десятков знаков, разобрать там что-либо становится не просто.
Но на помощь приходит Python и его стремление сделать нашу жизнь проще!
В функциях регулярок можно после паттерна указывать флаги, один из которых позволяет писать паттерны более свободно. А именно, добавлять пробелы и переносы, которые будут игнорированы. В результате мы можем разбить паттерн на строки и добавить комментов.
Чтобы это сработало нужно добавить флаг re.VERBOSE. Пробелы в паттерне теперь следует указывать явно спец символами.
Согласитесь, что даже с именованными группами а таком виде регэкспа выглядит вполне сносно 😉.
#tricks#regex
Also there will be a scheduled downtime for two remaining bots tomorrow, in about 16h 20h from now :
- @BanWarnBot
- @RulesRulesBot
Those have a database, and therefore they need to be take down to not loose any changes happining while the data is moved over.
#scheduled#downtime
https://docs.python.org/3/library/asyncio-dev.html#asyncio-coroutine-not-scheduled
18.5.9.6. Detect #coroutine objects never #scheduled
When a coroutine function is called and its result is not passed to ensure_future() or to the BaseEventLoop.create_task() method, the execution of the coroutine object will never be scheduled which is probably a bug. Enable the debug mode of asyncio to log a warning to detect it.
Example with the bug:
import asyncio
@asyncio.coroutine
def test():
print("never scheduled")
test()
Output in debug mode:
Coroutine test() at test.py:3 was never yielded from
Coroutine object created at (most recent call last):
File "test.py", line 7, in <module>
test()
The fix is to call the ensure_future() function or the BaseEventLoop.create_task() method with the coroutine object.