@verse · Post #108 · 20.07.2024 г., 12:58
Cycling alone Past Andrew Wyeth fields – No lid on the world! #haiku by MR
Hashtags
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
Пребарај: #haiku
@verse · Post #108 · 20.07.2024 г., 12:58
Cycling alone Past Andrew Wyeth fields – No lid on the world! #haiku by MR
Hashtags
@PensivePost · Post #5246 · 31.05.2021 г., 07:56
Relationship. On a lonely night, Two strangers bumped into eachother. And a relationship bloomed. #review#haiku
@QuietWorld · Post #6840 · 31.10.2019 г., 23:30
🔖Haiku 🌸“To sleep on our thoughts, Is better than to lose sleep over rash actions” #haiku#life#wisdom @quietworld🍃
@QuietWorld · Post #6766 · 22.10.2019 г., 13:01
🔖Haiku 🌸“When cherry blossoms scatter, no regrets.” .·. even when the cherry blossoms live for only a short period of time, they fall to their death with no regrets – because they offered beauty and loveliness around them. #haiku#life#kindness @quietworld🍃
@PensivePost · Post #5276 · 05.06.2021 г., 14:33
Mind had no more muse The poet in me, died and rot And my haiku cried. #review#haiku#nandini
@PensivePost · Post #5713 · 06.05.2022 г., 13:01
#review#iam#haiku Is this the demise of the unique journey?? If yes!!! Then what else is there in our stores?? Sounds meaningless!!!
@PensivePost · Post #5309 · 18.06.2021 г., 11:16
Haiku Sunshine after rain, Droplets on the spider web Glisten on and off. #review#haiku#Florence
@PensivePost · Post #5300 · 16.06.2021 г., 06:16
Haiku The storm raged outside Frightening the little blue birds And rain fell sideways. #haiku#review#Florence
@PensivePost · Post #5296 · 15.06.2021 г., 07:09
Haiku Look at the prim rose Rain-soaked, wind-kissed and enticed Emanating joy! #haiku#review#Florence
@PensivePost · Post #5275 · 05.06.2021 г., 13:52
Haiku Flowers in garden Basking in the petrichor Sway in balmy wind. #review#haiku#Florence
@PensivePost · Post #5247 · 31.05.2021 г., 17:15
Haiku Dark grey clouds gathered, A drop of rain on my nose Eruption of joy! #review#haiku#Florence
@PensivePost · Post #5236 · 29.05.2021 г., 13:33
HaikuHaiku A blooming red rose With raindrops like pearls Blushes like a bride. #review#haiku#Florence