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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #418 · 9 мар.

Оператор pipe позволяет писать более компактный код, реализуя логику объединения данных (Union). Важно помнить, что его поведение зависит от контекста. Побитовые операции (логическое OR) result = 5 | 3 # 5 (0101) | 3 (0011) = 7 (0111) Самое главное - не путать с оператором or, это другое! Объединение множеств set_a = {1, 2, 3} set_b = {3, 4, 5} set_c = set_a | set_b # {1, 2, 3, 4, 5} set_c |= {5, 6} # {1, 2, 3, 4, 5, 6} Слияние словарей dict_1 = {"a": 1, "b": 2} dict_2 = {"b": 3, "c": 4} merged = dict_1 | dict_2 # {'a': 1, 'b': 3, 'c': 4} merged |= {"d": 5} # {'a': 1, 'b': 3, 'c': 4, 'd': 5} Аннотации типов, заменяет Union def process_data(value: int | str) -> None: print(value) Допустимо использовать в isinstance или issubclass isinstance(3, int | float) # True Паттерн-матчинг status_code = 404 match status_code: case 200 | 201 | 204: print("OK") case 400 | 404 | 500: print("ERROR") Для использования в своих классах требуется переопределить метод __or__ Так же нашел библиотеку pipe которая добавляет еще много возможностей. Рекомендую ознакомиться ;) #basic

Hashtags

Резултати

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

Пребарај: #scotsgreen

当前筛选 #scotsgreen清除筛选
Ultimora.net - POLITICS

@UltimoraPOlitics · Post #38559 · 06.05.2022 г., 16:23

#Elezioni#RegnoUnito#Scozia#Amministrative Risultati definitivi: #SNP|G/EFA: 451 seggi (+24) #LAB|S&D: 278 (+18) #CON|ECR: 212 (-61) Indipendenti: 151 (-16) #LDEM|RE: 84 (+20) #ScotsGreen|G/EFA: 34 (+15) Consigli vinti: Senza controllo: 27 (-2) Indipendenti: 3 #SNP|G/EFA: 1 (+1) #LAB|S&D: 1 (+1) @UltimoraPolitics

Ultimora.net - POLITICS

@UltimoraPOlitics · Post #38551 · 06.05.2022 г., 16:03

#Elezioni#RegnoUnito#Scozia#Amministrative 29 consigli scrutinati su 32: #SNP|G/EFA: 442 seggi (+24) #LAB|S&D: 273 (+18) #CON|ECR: 200 (-61) Indipendenti: 148 (-17) #LDEM|RE: 83 (+22) #ScotsGreen|G/EFA: 34 (+15) Consigli vinti: Senza controllo: 24 (-2) Indipendenti: 3 #SNP|G/EFA: 1 (+1) #LAB|S&D: 1 (+1) @UltimoraPolitics

Ultimora.net - POLITICS

@UltimoraPOlitics · Post #38534 · 06.05.2022 г., 15:34

#Elezioni#RegnoUnito#Scozia#Amministrative 24 consigli scrutinati su 32: #SNP|G/EFA: 407 seggi (+23) #LAB|S&D: 250 (+17) #CON|ECR: 182 (-54) Indipendenti: 139 (-13) #LDEM|RE: 70 (+16) #ScotsGreen|G/EFA: 22 (+11) Consigli vinti: Senza controllo: 19 (-2) Indipendenti: 3 #SNP|G/EFA: 1 (+1) #LAB|S&D: 1 (+1) @UltimoraPolitics

Ultimora.net - POLITICS

@UltimoraPOlitics · Post #38521 · 06.05.2022 г., 14:47

#Elezioni#RegnoUnito#Scozia#Amministrative 18 consigli scrutinati su 32: #SNP|G/EFA: 359 seggi (+21) #LAB|S&D: 214 (+15) #CON|ECR: 167 (-50) Indipendenti: 136 (-13) #LDEM|RE: 68 (+17) #ScotsGreen|G/EFA: 19 (+10) Consigli vinti: Senza controllo: 13 (-2) Indipendenti: 3 #SNP|G/EFA: 1 (+1) #LAB|S&D: 1 (+1) @UltimoraPolitics

Ultimora.net - POLITICS

@UltimoraPOlitics · Post #38495 · 06.05.2022 г., 12:55

#Elezioni#RegnoUnito#Scozia#Amministrative 6 consigli scrutinati su 32: #SNP|G/EFA: 167 seggi (+8) #LAB|S&D: 99 (+7) Indipendenti: 90 (-9) #CON|ECR: 81 (-21) #LDEM|RE: 24 (+7) #ScotsGreen|G/EFA: 13 (+8) Associazioni dei residenti: 1 (+1) Consigli vinti: Indipendenti: 3 Senza controllo: 2 (-1) #LAB|S&D: 1 (+1) @UltimoraPolitics

Ultimora.net - POLITICS

@UltimoraPOlitics · Post #38554 · 06.05.2022 г., 16:10

#Elezioni#RegnoUnito#Amministrative Dati aggregati #Inghilterra, #Scozia e #Galles, 166 consigli scrutinati su 200: #LAB|S&D: 2137 (+104) #CON|ECR: 1161 (-379) #LDEM|RE: 683 (+193) #SNP|G/EFA: 442 seggi (+24) Indipendenti: 437 (-26) #Green|G/EFA: 101 (+59) #PC|G/EFA: 73 (+2) Associazioni dei residenti: 51 (+10) #ScotsGreen|G/EFA: 34 (+15) #Reform|Destra anti-lockdown: 2 (+2) #SDP|Centro-sinistra euroscettico conservatore: 1 (+1) #UKIP|Destra: 0 (-3) @UltimoraPolitics