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

Резултати

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

Пребарај: #wtf

当前筛选 #wtf清除筛选

Curated Crypto | ꘜ 🤑WTF: ETH options open interest just hit a 1.5-year high! Degens are loading up on longs, while whales are stacking ETH at all-time record pace! But hedge funds are going mega short - CME ETH futures short positioning just keeps smashing new records! Green But Red in real life! #WTF

Hashtags

Viral Today

@viral_today · Post #3327 · 23.06.2025 г., 15:31

An Italian car enthusiast built the world’s narrowest fully functional car based on a Fiat Panda @Viral_Today / #wtf

Hashtags

Viral Today

@viral_today · Post #3235 · 22.11.2024 г., 13:30

When too many kids want to sled, you just connect 47 sleds to one tractor and call it a day! @Viral_Today / #wtf

Hashtags

Viral Today

@viral_today · Post #3224 · 18.11.2024 г., 15:30

The suspect attempted to escape an interrogation room by breaking through the wall while no one was watching—only to be caught shortly after. @Viral_Today / #wtf

Hashtags

Viral Today

@viral_today · Post #3216 · 16.11.2024 г., 12:30

When you drive an electric car but miss the roar of an engine, so you get creative with sound effects @Viral_Today / #wtf

Hashtags

Viral Today

@viral_today · Post #3158 · 26.10.2024 г., 17:28

Imagine a coffee table that moves around the house by itself—well, you don’t have to anymore because it’s real. It’s just as fascinating as it is creepy. @Viral_Today / #wtf

Hashtags

123•••5•••10•••15•••20•••25•••30•••35•••40•••45•••50•••5556
ПретходнаСтраница 1 од 56Следна