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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #156 · 2 окт.

Те, кто в Python не первый день, хорошо знают, что на число можно умножить не только число, но и другие типы. Главное, чтобы у этих типов была реализация такой операции. # list >>> [1] * 3 [1, 1, 1] # tuple >>> (2, 3) * 3 (2, 3, 2, 3, 2, 3) # string >>> "A" * 3 "AAA" Так работает полиморфизм стандартных типов. Интересно здесь то, что это сработает и в том случае, когда порядок операндов обратный. То есть int умножить на [тип]. # list >>> 3 * [1] [1, 1, 1] # tuple >>> 3 * (2, 3) (2, 3, 2, 3, 2, 3) # string >>> 3 * "A" "AAA" Если хотите реализовать такое поведение в ваших классах то следует помнить два момента: 1. Если множитель справа, то вам нужно реализовать метод __mul__, наш класс это первый операнд, то есть слева. myType * 3 2. Если множитель слева, то вам нужно реализовать метод __rmul__, наш класс это второй операнд, справа. 3* myType Всё тоже самое можно делать и для других математических операторов. И если в этом примере действие и результат будут фактически одинаковыми, то бывают ситуации, когда это не так. Например, при умножении матриц имеет значение порядок операндов. Для других операторов, таких как деление или сдвиг, очень важно кто с какой стороны находится. >>> 2/4, 4/2 (0.5, 2.0) >>> 2<<3, 3<<2 (16, 12) >>> 100%15, 15%100 (10, 15) #tricks#basic

Резултати

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

Пребарај: #gazacrisis

当前筛选 #gazacrisis清除筛选
BadVolf

@badvolfnews · Post #1359 · 22.12.2023 г., 04:25

🚨URGENT🚨 Gaza in crisis‼️ Hunger levels at an all-time high🔴 Famine risk escalating daily💔 UN report reveals entire population facing acute food insecurity😱 No nourishment = weakened immune systems🤒 Disease outbreaks imminent🆘 Humanitarian aid urgently needed💔 #GazaCrisis https://www.aljazeera.com/news/2023/12/21/entire-gaza-population-facing-hunger-crisis-famine-risk-un-backed-report Subscribe to @BadVolfNews

Hashtags

BadVolf

@badvolfnews · Post #1243 · 09.11.2023 г., 09:25

🚨 Urgent Call for Ceasefire in Gaza 🚨 USAID staff demand immediate end to violence, decrying civilian deaths and violations of international law. Aid efforts futile amidst indiscriminate bombing. Gaza needs more than just aid, it needs the bombs to stop. Pressure mounts on US government to take action, hold all parties accountable. UN warns of grave risk of genocide. Meanwhile, US continues unwavering support for Israel, providing billions in military aid. Will Congress break the silence? #CeasefireNow#GazaCrisis https://www.aljazeera.com/news/2023/11/8/more-than-1000-usaid-employees-sign-letter-backing-gaza-ceasefire Subscribe to @BadVolfNews

BadVolf

@badvolfnews · Post #1197 · 01.11.2023 г., 12:25

UN chief warns of "immense suffering" as Gaza aid remains inadequate. Israel's relentless bombardment overwhelms hospitals and leaves Gaza without essential supplies. More than 8,500 lives, including children, have been lost. The situation is "absolutely horrific", says Red Crescent. Calls for a ceasefire and increased humanitarian aid are rejected by the US, prioritizing their support for Israel. As the death toll rises, the UN pleads for an end to this "spiral of death". The world must act now to prevent further tragedy. #GazaCrisis#HumanitarianAid https://www.aljazeera.com/news/2023/10/31/un-chief-guterres-says-aid-trickling-into-gaza-is-completely Subscribe to @BadVolfNews

BadVolf

@badvolfnews · Post #1122 · 12.10.2023 г., 09:25

⚠️ Update: US officials report 17 Americans missing amidst Israel-Hamas war. Death toll of US citizens rises to 22. Hostages held by Hamas confirmed, but numbers are unclear. US Secretary of State Blinken warns death toll could increase. US military deploys second aircraft carrier. Israeli blockade intensifies, cutting off supplies to 2.3 million Palestinians. Nonstop Israeli air raids devastate Gaza, killing over 1,055 people. Efforts underway to secure safe passage for civilians. Victims caught in the crossfire. #IsraelHamasWar#GazaCrisis https://www.aljazeera.com/news/2023/10/11/us-death-toll-in-israel-hamas-war-rises-to-22-officials Subscribe to @BadVolfNews

Marwa Osman/MidEaStream

@Marwa_OsmanLB · Post #3200 · 13.09.2024 г., 12:32

Eva Bartlett @Reality_Theories talks about how Israeli policies have turned Gaza into a disaster zone, fostering starvation and disease. Full episode: https://youtu.be/ntHkkCGyfdo #GazaCrisis#IsraeliPolicies#EvaBartlett#MiddleEast#Israel#Palestine