TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #22 · 19 јан.

Заметка начинающим, которые часто сталкиваются с подобной непоняткой. Ситуация следующая, есть список файлов: names = [ 'image.bmp', 'second.txt.bkp', 'data.db', '.config.cfg', 'file.ext.bkp' ] И мы хотим убрать у них окончание ".bkp". Не знаю зачем, пример довольно надуманный) Но суть он показывает, а это главное. Те, кто еще не очень знаком с библиотекой os.path или pathlib, вероятно решат обработать имена как строки. И тут вполне подойдет метод строки strip(). Что делает этот метод? Он отрезает указанные символы по обеим сторонам строки. Если ничего не указать, то убирает невидимые символы (пробелы, табуляции и переносы строк). В нашем случае будет выглядеть вот так: >>> name.strip('.bkp') То есть просим удалить строку '.bkp' по краям имени файла, если таковая есть. Можно применить аналогичный метод rstrip(), чтобы отрезать только справа, но для этого примера используем обычный. >>> for name in names: >>> print(name.strip('.bkp')) image.bm second.txt data.d config.cfg file.ext Хм, что-то не то с нашими именами! Что случилось??? Видим нежелательное переименование в именах, где и близко не было указанной строки '.bkp' А дело всё в том, что данный метод ищет не указанную строку, а указанные символы, и не важно в каком порядке. Для метода strip() строка '.bkp' это не паттерн для поискаа список символов. Потому он отрезал симовол 'p' от '.bmp' и удалил точку из файла '.config.cfg'. Как тогда правильно заменить именно паттерн? Для начинающего можно посоветовать метод строки replace(), который как раз использует для замены указанную строку целиком. В нашем примере заменим её на пустую строку. >>> for name in names: >>> print(name.replace('.bkp', '')) image.bmp second.txt data.db .config.cfg file.ext Уже лучше, но помните, это лишь пример про strip(). Для работы с именами файлов есть способы и более "правильные", дающие однозначно верный результат. Я взял файлы только в качестве примера. Даже replase() тут может сделать не то что ожидаем. Просто впредь будьте внимательны с этим strip(). #basic

Hashtags

Резултати

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

Пребарај: #euai

当前筛选 #euai清除筛选
AI & Law

@ai_and_law · Post #720 · 10.12.2025 г., 08:04

🇪🇺EU FRA Flags Rights Risks in High-Risk AI Deployment The EU Agency for Fundamental Rights has released a report showing that many developers and deployers of high-risk AI systems lack the knowledge or tools to mitigate impacts on fundamental rights. The assessment covers the use of such systems in asylum procedures, education, employment, law enforcement, and the administration of public benefits: areas where algorithmic decisions can directly affect access to essential services and legal protections. The FRA recommends expanding the definition of AI to better reflect fundamental-rights considerations and issuing clear guidance on how to conduct impact assessments. According to the report, these steps are necessary to ensure that high-risk AI systems are developed and deployed in ways that do not compromise individuals’ rights across critical public domains. #AIandLaw#FundamentalRights#EUAI#AIRegulation

AI & Law

@ai_and_law · Post #436 · 06.11.2024 г., 08:04

Strengthening the EU’s AI Leadership Through Investment and Strategic Governance The EU Council has endorsed the European Court of Auditors’ call to elevate AI ambitions within the EU, emphasizing increased, targeted investments and enhanced governance. Recognizing AI’s potential to drive Europe’s global competitiveness, the Council urges a focus on fostering AI talent and creating an ecosystem built on excellence and trust. Moreover, the Council highlights the importance of considering environmental impacts, especially in energy efficiency and the reliability of the hardware supply chain, as the EU moves forward with AI policies. By reinforcing collaboration with member states and international partners, the EU aims to position itself as a global leader and benchmark in AI governance. #AIGovernance#EUAI#SustainableAI #

AI & Law

@ai_and_law · Post #761 · 10.02.2026 г., 08:04

🇪🇺European Parliament Pushes New Copyright Safeguards for AI The European Parliament’s Committee on Legal Affairs has approved an own-initiative report proposing new measures to strengthen copyright protection in the context of generative AI. The proposals include mandatory transparency obligations on training data practices for all generative AI systems placed on the EU market. MEPs also call for remuneration mechanisms for rightsholders and the development of voluntary, sector-specific collective licensing agreements. The report is not legally binding but signals political direction and will be submitted for a vote by the full Parliament during the March plenary session. #AIandCopyright#EUAI#GenerativeAI#CopyrightLaw#AIRegulation

AI & Law

@ai_and_law · Post #73 · 02.08.2023 г., 07:04

Leading the Way in Responsible AI: The EU's Vital Opportunity Hello, AI enthusiasts! Today, we share a policy brief by Pegah Maham and Sabrina Küspert from the Stiftung Neue Verantwortung. They highlight the EU's significant chance to take the lead in responsible AI development through the AI Act and beyond. But to seize this opportunity, understanding the risks associated with general-purpose AI models is essential. 🔹 Risks from Unreliability: One major concern is the lack of control over AI models' behavior. This unreliability could lead to serious issues like discrimination and stereotype reproduction, spreading misinformation, and violating individual privacy. 🔹 Misuse and Dual-Use AI Models: The dual-use nature of some AI models poses another challenge. While they offer immense benefits, they can also be misused by malicious actors for cybercrime, biosecurity threats, and politically motivated purposes. 🔹 Systemic Risks: As AI rapidly integrates into our society, systemic risks emerge. These risks include economic power concentration and inequality, ideological homogenization, and disruptions from the lagging adaptation of society. By comprehending and addressing these risks, the EU can establish itself as a global leader in responsible AI development. #ResponsibleAI#AIRegulation#AIAct#AIChallenges#EUAI#TechPolicy#DigitalFuture#AICommunity