Реализация цикла for с помощью функции и цикла while
#algoritms #iterator #exceptions
def for_loop(iterable, loop_body_func):Здесь использовали конструкцию try-else. Она позволяет выполнять код, если исключения не возникло, и код был выполнен успешно.
iterator = iter(iterable)
next_element_exist = True
while next_element_exist:
try:
element_from_iterator = next(iterator)
except StopIteration:
next_element_exist = False
else:
loop_body_func(element_from_iterator)
#algoritms #iterator #exceptions
https://medium.com/@yeraydiazdiaz/asyncio-coroutine-patterns-errors-and-cancellation-3bb422e961ff - пример по обработке ошибок и логгированию с asyncio
#asyncio #exceptions #logging
#asyncio #exceptions #logging
Medium
Asyncio Coroutine Patterns: Errors and cancellation
This is the second part of a two part series on coroutine patterns in asyncio, to fully benefit from this article please read the first…