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

Резултати

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

Пребарај: #bone

当前筛选 #bone清除筛选

DogData community🐾 Everyone should be interested in getting this. Let's show that we are big, let's show that our community is huge ❗️❗️ Support us and vote for DogData🙏🐾 Please tag 👇 @FaceBook4Dog#ethbn#bone#dogdata https://twitter.com/gate_io/status/1293863802019119105?s=09 👆👆👆

ETH 🐾 BoNe 🦴 token 📈 📊CEX Probit📈🦴🐶 https://www.probit.com/app/exchange/BONE-USDT 📊https://www.dextools.io/app/en/ether/pair-explorer/0x75a9d7ef9eeb3370e20df491c4153ac2b89a6afe?t=1747303206588 CA : 0x5c84bc60a796534bfec3439af0e6db616a966335 Trade DEX : GMGN https://gmgn.ai/eth/token/0x5c84bc60a796534bfec3439af0e6db616a966335 #BONE#BONES#Probit#ETH 🐾🦴🔷🍖🐶🐾🦴🔷🍖🐶

Website : https://bonetoken.com ETH 🐾 BoNe 🦴 token 📊CEX Probit📈🦴🐶 https://www.probit.com/app/exchange/BONE-USDT 📊https://www.dextools.io/app/en/ether/pair-explorer/0x75a9d7ef9eeb3370e20df491c4153ac2b89a6afe?t=1747303206588 CA : 0x5c84bc60a796534bfec3439af0e6db616a966335 Trade DEX : GMGN https://gmgn.ai/eth/token/0x5c84bc60a796534bfec3439af0e6db616a966335 🐾🦴🔷🍖🐶🐾🦴🔷🍖🐶 #BONE#BONES#Uniswap#meme