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

Резултати

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

Пребарај: #digitalreplicas

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

@ai_and_law · Post #173 · 24.11.2023 г., 08:04

SAG-AFTRA's Post-Strike Contract Raises Alarms on AI Usage Hello, dear subscribers! The tentative agreement between SAG-AFTRA and the Alliance of Motion Picture and Television Producers (AMPTP) that signals the potential end to the ongoing labor strike has taken an unexpected turn. While there's hope for the strike to conclude, concerns are emerging regarding the contract's stance on the use of artificial intelligence and its potential impact on actors. Disagreements over the digital capture, perpetual ownership, and usage of actors' likenesses by Hollywood studios have been key reasons behind the strike. The tentative contract introduces provisions related to generative AI technology, sparking worries about the extent of responsibility placed on studios. The contract's ambiguous wording around "unprecedented provisions for consent and compensation that will protect members from the threat of AI" has raised questions about how effectively it safeguards actors. Notably, nearly 14% of SAG-AFTRA's National Board opposed moving forward, indicating reservations within the union. The agreement introduces new definitions for digital replicas, emphasizing the need for clear and advance consent from actors. However, critics, including former SAG-AFTRA board member Justine Bateman, express concerns about potential loopholes favoring studios. The summary's of tentative agreement mention of actors potentially competing with AI objects for roles is seen as a significant drawback. While the strike officially ended on November 9th, the summary specifies that AMPTP only has to "endeavor to comply" until the contract is ratified. The lack of detail on enforcement mechanisms and the expansive powers given to studios in post-production edits raise concerns about actors' control over their digital replicas. As the union heads toward a ratification vote on December 5th, many questions remain unanswered. The summary's lack of clarity on specific terms for substantial changes triggering contractual mechanisms raises uncertainties about the practicalities of AI usage in the industry. #SAGAFTRA#AI#EntertainmentIndustry#LaborStrike#DigitalReplicas