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

Резултати

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

Пребарај: #eucommission

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

@ai_and_law · Post #17 · 06.06.2023 г., 07:04

Transparency in AI-generated content: EU Commissioner calls for labeling EU Commissioner Vera Jourova has highlighted the importance of clearly identifying content that is generated or significantly influenced by AI systems. The proposal to label AI-generated content serves multiple purposes: protecting consumer rights, promoting accountability, and enabling individuals to distinguish between human-created and AI-generated information. The European Commission wants tech companies like Google, Facebook and TikTok to start labeling content created by artificial intelligence without waiting for digital laws to come into effect. As AI becomes more prevalent in content creation, legal concerns arise regarding authenticity, accountability, and the potential for misinformation. By introducing labeling requirements, the EU aims to provide legal clarity, allowing consumers and authorities to better navigate the digital landscape while holding AI systems accountable for the information they generate. While the EU takes a proactive stance in regulating AI-generated content, the implications extend beyond its borders. As AI transcends geographical boundaries, the need for transparent labeling practices becomes crucial on a global scale. International collaboration in developing standardized guidelines can enhance consistency and protect users' rights across jurisdictions. #artificialintelligence#AI#Law#EUCommission

AI & Law

@ai_and_law · Post #348 · 09.07.2024 г., 07:04

European Commission's AI Codes of Practice: A Self-Regulation Concern? According to Euractiv, the European Commission plans to let AI model providers draft codes of practice for compliance with the AI Act, with civil society organizations consulted during the process. This approach has sparked concerns about industry self-regulation, as these codes will serve as compliance measures for general-purpose AI models until harmonized standards are set. The Commission may grant EU-wide validity to these codes through an implementing act. Some civil society members worry this could enable Big Tech to essentially write their own rules. The AI Act's language on stakeholder participation in drafting these codes is ambiguous. The Commission has stated that an upcoming call for expressions of interest will clarify how various stakeholders, including civil society, will be involved. However, specifics are still lacking. An external firm will be hired to manage the drafting process, including stakeholder engagement and weekly working group meetings. The AI Office will oversee the process but will primarily focus on approving the final codes. #AIRegulation#EUCommission#AICodes#AIAct#Compliance

AI & Law

@ai_and_law · Post #55 · 13.07.2023 г., 11:20

Spain takes the lead inshaping EU's AI regulations Spain has assumed the rotating presidency of the EU Council of Ministers and is gearing up to make a significant impact on the future of artificial intelligence regulations in the European Union. As part of their digital priorities, Spain aims to reach a political agreement on the AI Act. In preparation for upcoming negotiations with the EU Council, Parliament, and Commission, Spain has shared its position on key aspects of the Act: 1️⃣ Defining AI: Spain is considering different options, including sticking with the Council's text, aligning with the Parliament's position, or awaiting the OECD's (Organisation for Economic Co-operation and Development) guidance. 2️⃣ Classification of High-Risk Applications: Spain is exploring various possibilities, such as adopting the Parliament's version without the notification of competent authorities, or refining it with binding self-assessment criteria for AI providers. 3️⃣ Addressing Critical Concepts: Spain is examining whether the AI Act is the appropriate framework to address concepts like democracy, the rule of law, and sustainability. 4️⃣ Clarity in Terminology: Spain is assessing the potential introduction of the term 'deployer' to minimize confusion and ensure clear roles and responsibilities within the AI ecosystem. These discussions will inform the trilogue negotiations scheduled for 18 July, where representatives from the Council, Parliament, and Commission will work towards a consensus on the AI Act. #SpainPresidency#AIAgenda#EURegulations#AIAct#AIRegulations#EUCouncil#EUCommission#EUParliament#Trilogue