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

Резултати

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

Пребарај: #prodemocracyprimary

当前筛选 #prodemocracyprimary清除筛选
Hong Kong Democracy Movement

@hkdmovement · Post #7911 · 23.11.2024 г., 19:57

在判刑前夕,前港督、香港監察贊助人彭定康發表聲明,形容47人案是港府對香港人的侮辱,也是對全球珍視權利和自由的人的侮辱。他譴責該案件在沒有陪審團的情況下作出的「虛假判刑」,並揭示了香港集會、言論和新聞自由的破壞。 我們必須繼續為民主和自由而戰,捍衛每一位政治犯的權利! #彭定康#47人案#民主派初選#國安法#顛覆國家政權#政治犯#欲加之罪#冤獄#莫須有#初選無罪#釋放政治犯 圖片來源 @rfacantonese Chris Patten’s Support for Hong Kong Democracy On the eve of sentencing, former Governor of Hong Kong and patron of Hong Kong Watch, Chris Patten, issued a statement describing the 47-person case as an insult to the people of Hong Kong and to all who value rights and freedoms globally. He condemned the "sham convictions" made without a jury, revealing the destruction of assembly, speech, and press freedoms in Hong Kong. We must continue to fight for democracy and freedom, defending the rights of every political prisoner! #ChrisPatten#47PersonCase#ProDemocracyPrimary#NationalSecurityLaw#Subversion#PoliticalPrisoners#FalseCharges#Injustice#Unfounded#InnocentInPrimaries#FreePoliticalPrisoners Photo credit to @rfacantonese