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 слични објави

Пребарај: #copyrightprotection

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

@ai_and_law · Post #77 · 07.08.2023 г., 07:04

Copyright in the Age of AI: Artists Take a Stand Hey there, AI & Law community! Have you ever wondered about the complex interplay between art and artificial intelligence? A recent legal battle is shedding light on how AI-generated content intersects with copyright law. Imagine discovering that your artwork has been used to train an AI system without your consent. That's exactly what happened to Kelly McKernan, a talented watercolor and acrylic illustrator. She found her creations uploaded to the LAION dataset, fueling AI image generators. This revelation transformed her relationship with her art, raising concerns about her career and the rights of countless creators. Kelly McKernan isn't alone in her struggle. Alongside cartoonist Sarah Anderson and illustrator Karla Ortiz, she's taking a stand against AI firm Stability AI, the company behind Stable Diffusion, Midjourney, and DeviantArt. These artists are filing a lawsuit, questioning the use of their work to train AI systems. This legal challenge adds to a growing list of cases that highlight the copyright complexities brought about by AI. Artists worldwide are coming together to address the concerns surrounding AI's impact on their creations. The European Guild of Artificial Intelligence Regulation is a prime example, aiming to create legislation that safeguards artists from predatory AI practices. The lack of protective measures and the potential for AI-generated art to replace human creativity is a pressing issue that demands attention. The case brings to the forefront the need for updated copyright laws in the face of AI advancements. The current framework often falls short in addressing the challenges posed by generative AI. #AIandArt#CopyrightProtection#ArtificialIntelligence#AIinLaw

AI & Law

@ai_and_law · Post #87 · 18.08.2023 г., 07:04

US: News Outlets Call for Transparency in AI Data Usage Hello everyone! A collective of news organizations has issued an open letter advocating for stricter regulations to safeguard copyright and ensure transparency in the use of training data for generative AI models. The open letter urges global lawmakers to enforce rules demanding data transparency, rights holders' consent for training data usage, and provisions for media companies to negotiate with AI model operators. It also calls for AI firms to tackle bias and misinformation and identify AI-generated content. Signatories include Agence France-Presse, Getty Images, The Associated Press, and more. They argue that foundation models using media content without proper consideration undermine media diversity and financial viability. The call comes in light of Google's AI news writing tool and concerns over AI training on copyrighted content. The US Senate and legal cases have addressed these issues, emphasizing the need to protect creators' rights. #AIandMedia#AIRegulation#DataTransparency#CopyrightProtection

AI & Law

@ai_and_law · Post #27 · 14.06.2023 г., 07:04

Balancing AI regulation and copyright protection: lessons from China's Generative AI Law Kris Shrishak, Senior Fellow at the Irish Council for Civil Liberties, urges the EU to take inspiration from China's draft law on generative AI. Shrishak highlights the EU's progress in regulating AI while underscoring its oversight in addressing the use of copyrighted material. China's draft law stands out for its explicit prohibition of unconsented use of copyright-protected content and personal data for training AI models. Shrishak points out that while the EU has taken steps to address AI risks, it primarily relies on self-assessments by AI developers rather than robust third-party assessments. This approach could potentially lead to enforcement challenges, as seen with the General Data Protection Regulation (GDPR). Learning from China's draft law, the EU can enhance its AI Act by incorporating stricter provisions against unconsented use of copyrighted content and personal data. Implementing third-party assessments and robust enforcement mechanisms will bolster intellectual property rights and privacy protection. #AIRegulation#CopyrightProtection#GenerativeAI#EU#China#DataProtection#Ethics#AIAct#Enforcement#PrivacyProtection