TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #401 · 15 дек.

Функция asyncio.wait() это еще один способ вызвать множество асинхронных задач. Она работает в нескольких режимах. 1. Самый простой - ждем завершения всех задач async def main(): tasks = [asyncio.create_task(do_it(i)) for i in range(10)] done, pending = await asyncio.wait( tasks, return_when=asyncio.ALL_COMPLETED ) for task in done: try: print(task.result()) except Exception as e: print(e) Очень похоже на gather, но работает не так. ▫️возвращает не результаты, а два сета с объектами Task у которых можно забрать результат через task.result() если они в списке done ▫️не гарантирует порядок результатов так как оба объекта это set ▫️не выбрасывает исключение когда оно появляется, а сохраняет его в Task. Исключение появится когда попробуете забрать резултьтат. 2. Ждем завершения первой задачи, даже если там ошибка. async def main(): tasks = [asyncio.create_task(do_it(i)) for i in range(3)] done, pending = await asyncio.wait( tasks, return_when=asyncio.FIRST_COMPLETED ) # в done может быть несколько задач! for task in done: try: print(task.result()) except Exception as e: print(f"Fail: {e}") # Оставшиеся задачи в pending, как правило, нужно отменить, иначе они будут продолжать работать for task in pending: task.cancel() В сете done будут таски которые успели завершится, причем как успешно так и нет. 3. До первой ошибки. Тоже самое, но с аргументом FIRST_EXCEPTION done, pending = await asyncio.wait( tasks, return_when=asyncio.FIRST_EXCEPTION ) Функция завершается как только первая задача упадет с ошибкой. Учтите, что в любом случае done вы можете обранужить несколько задач, как с ошибками так и успешные. ↗️ Полный листинг примеров здесь #async

Hashtags

Резултати

Пронајдени 73 слични објави

Пребарај: #pretty

当前筛选 #pretty清除筛选
America 🇺🇸 News & Politics

@America · Post #10038 · 30.10.2025 г., 02:33

😄Pretty ➖➖➖➖➖➖ 🔘Pretty as an adjective means 'attractive, especially when talking about girls or women'. Margo always tells her daughter that she's pretty.Margo always tells her daughter that she's pretty. 🔜Jacob's mum is really pretty. 🔘Pretty is also used to talk about things that are 'pleasant to look at in a delicate or charming way'. While this is often connected to females, it can also be used to describe something like 'a view'. 🔜There's a very pretty view at the top of that hill. 🔜My friend moved out of the city and bought a pretty cottage in the countryside. 🔘As an adverb, pretty can be an informal way of saying 'quite' or 'rather'. 🔜The house was built recently, it's pretty new. 🔜I enjoyed that film, it was pretty good. 🔘We can also use pretty to give emphasis. 🔜We went to bed at 2am, so we were pretty tired. 🔜I'm pretty angry right now, so don't talk to me. #Pretty👨‍🏫@America ➖➖➖➖➖➖➖➖➖➖➖➖ 🆕 Crypto News @Money 😁 Crypto Game @Egame 🇺🇸 US News @America 🇯🇵 Japan News @Japan 🇦🇪 UAE News @Dubai ▶️ Popular Movies @Videos 😜 Best Funny Video @Funnys

Hashtags

😄Pretty ➖➖➖➖➖➖ 🔘Pretty as an adjective means 'attractive, especially when talking about girls or women'. Margo always tells her daughter that she's pretty.Margo always tells her daughter that she's pretty. 🔜Jacob's mum is really pretty. 🔘Pretty is also used to talk about things that are 'pleasant to look at in a delicate or charming way'. While this is often connected to females, it can also be used to describe something like 'a view'. 🔜There's a very pretty view at the top of that hill. 🔜My friend moved out of the city and bought a pretty cottage in the countryside. 🔘As an adverb, pretty can be an informal way of saying 'quite' or 'rather'. 🔜The house was built recently, it's pretty new. 🔜I enjoyed that film, it was pretty good. 🔘We can also use pretty to give emphasis. 🔜We went to bed at 2am, so we were pretty tired. 🔜I'm pretty angry right now, so don't talk to me. #Pretty👨‍🏫@America ➖➖➖➖➖➖➖➖➖➖➖➖ 🆕 Crypto News @Money 😁 Crypto Game @Egame 🇺🇸 US News @America 🇯🇵 Japan News @Japan 🇦🇪 UAE News @Dubai ▶️ Popular Movies @Videos 😜 Best Funny Video @Funnys

Hashtags

djangoproject

@djangoproject · Post #206 · 06.12.2016 г., 15:28

http://www.enlistq.com/10-python-idioms-to-help-you-improve-your-code/ If you have ever tried to learn a new language (not a programming language), you know that we always think in our native language before we translate it to the new language. This can lead to you forming some sentences that don’t make sense in the new language but are perfectly normal in your native language. For example, in a lot of languages, you ‘open’ an electronic gadget such as fan, AC or cell phone. When you say that in English, it means to literally open the gadget instead of turning it on. The same is true for programming languages. As we pick up new languages, such as #python, we are using our prior knowledge of programming in another language (q, java, c++ etc) and translating that to python. Many times, your code will work but it won’t be ‘#pretty’ or #fast. In python terms, your code won’t be ‘#pythonic’.

123•••67
ПретходнаСтраница 1 од 7Следна