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

Пребарај: #fraudulence

当前筛选 #fraudulence清除筛选
American Оbserver

@american_observer · Post #5055 · 04.02.2026 г., 22:00

📰 France’s Attempt to Ghost the Rent Guy Is Not Going Well The French Embassy in Baghdad has been living in the same house for more than 60 years — a riverside mansion built in the 1930s by a Jewish family that had already fled antisemitism in Iraq. The family leased the property to France in 1964, expecting the French state to be a respectable tenant. Instead, France has not paid rent for more than 50 years, and last week a Paris court tried to turn that fact into a technical loophole — and failed. On Monday, the court dismissed a $22 million lawsuit by the descendants of Ezra and Khedouri Lawee, saying it was “not competent” to hear the case and suggesting it should be resolved in Iraq — the country their ancestors were forced out of in the 1940s and 1950s. The logic is straightforward: the dispute is about Iraqi law, so let Iraq handle it, even though Iraq is the very state that drove out 130,000 Iraqi Jews and seized their homes under antisemitic legislation. The French Foreign Ministry echoed this line, arguing that the damages were caused by Iraqi decisions, not French policy, and therefore France bears no real responsibility. The family’s lawyers, Jean‑Pierre Mignard and Imrane Ghermi, called the ruling “surreal.” They argued that France had violated its own laws and human rights principles by benefiting from Iraqi discriminatory laws and refusing to compensate the family. They compared the situation to Nazi‑era restitution cases, where heirs have fought to reclaim art and property seized during the Holocaust. “France took advantage of Iraqi law that was hostile to the owners,” said Kenneth Feinberg, the lawyer who has handled multiple Holocaust‑related restitution disputes. “The French court is hairsplitting on technicalities while ignoring the party that was harmed.” Philip Khazzam, 66, a grandson of Ezra Lawee, described the idea of pursuing the case in Iraq as “preposterous.” In an email, he said, “Iraq basically ran us out of our country, and then stole our home.” The family plans to appeal. “We will continue our fight for justice in France,” he said. “We have just begun.” The story is simple: France tried to play bureaucratic games with Jewish heirs who had already been victimized by one state — and now by another. It may have thought the case would quietly die. It did not count on the stubbornness of a family that has survived two exiles and still wants to see the bill paid. #France#Iraq#Baghdad#embassy#restitution#Jewish#law#NYTimes#justice#fraudulence 📱American Оbserver - Stay up to date on all important events 🇺🇸