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

Резултати

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

Пребарај: #libxml2

当前筛选 #libxml2清除筛选
AIGC

@aigcrubbish · Post #16 · 25.12.2024 г., 18:34

libxml2 在 2.11.9、2.12.9 和 2.13.3 之前的版本中存在一个安全漏洞,SAX 解析器在自定义 SAX 处理程序尝试通过设置 "checked" 来覆盖实体内容时,仍然会为外部实体生成事件。这使得经典的 XXE(XML 外部实体注入)攻击成为可能。 该漏洞已在后续版本中修复,建议用户尽快升级到最新版本以避免潜在的安全风险。 参考链接: - [GitHub 安全公告](https://github.com/advisories/GHSA-6c2p-rqx3-w4px) - [NVD 漏洞详情](https://nvd.nist.gov/vuln/detail/CVE-2024-40896) - [libxml2 修复提交](https://gitlab.gnome.org/GNOME/libxml2/-/commit/1a8932303969907f6572b1b6aac4081c56adb5c6) - [libxml2 问题报告](https://gitlab.gnome.org/GNOME/libxml2/-/issues/761) #安全漏洞#XXE#libxml2#SAX解析器 #AIGC

djangoproject

@djangoproject · Post #551 · 23.01.2018 г., 16:28

http://lxml.de/ #lxml is the most feature-rich and easy-to-use library for processing #XML and #HTML in the Python language. The lxml XML toolkit is a Pythonic binding for the #C libraries #libxml2 and #libxslt. It is unique in that it combines the speed and XML feature completeness of these libraries with the simplicity of a native Python #API, mostly compatible but superior to the well-known ElementTree API. The latest release works with all #CPython versions from 2.6 to 3.6. See the introduction for more information about background and goals of the lxml project. Some common questions are answered in the FAQ.