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

Резултати

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

Пребарај: #judiciary

当前筛选 #judiciary清除筛选
Indian Development News 🇮🇳

@developmentnewsindia · Post #44104 · 27.04.2026 г., 05:56

Calcutta HC (Single Bench) overturned the Election Commission order to Ban Bikes in Poll Bound Areas from 48 hrs to just 12 hrs. This Ban was imposed in Phase I but overturned on April 24. Now Election Commission has moved to Division Bench of Calcutta HC to appeal against this order. #Judiciary

Hashtags

Indian Development News 🇮🇳

@developmentnewsindia · Post #44013 · 24.04.2026 г., 07:03

Election Duty Officers move SC saying they themselves are not on West Bengal SIR List Se Adv MR Shamshad: These are 65 petitioners who are on Election duty. Their duty orders mention EPIC numbers. Now those numbers are deleted. Now the persons conducting elections cannot vote! This is on the face Arbitrary. Many not given reasons. CJI: Make these arguments before the Appellate Tribunal. Let the tribunal look into it. Justice Bagchi: Appropriate orders will be passed by the Tribunal. This election yes perhaps they can't vote. The more valuable right to remain on the Rolls shall be preserved. #Judiciary

Hashtags

Indian Development News 🇮🇳

@developmentnewsindia · Post #43911 · 22.04.2026 г., 09:12

Center says the SC "Government doesn't want to control the temple at all" Center also conveyed SC directly that it is not competent to decide on matters of belief and practices of Religious Denominations and should restrict itself to matters of Constitution. #Judiciary

Hashtags

Indian Development News 🇮🇳

@developmentnewsindia · Post #43409 · 09.04.2026 г., 16:06

Center to Supreme Court Decriminalising adultery and Same-Sex consensual relationships were based on a "subjective" interpretation of constitutional morality and should be considered "not a good law." Solicitor General Tushar Mehta – " Constitutional morality" is a vague concept and cannot serve as a standalone test for Judicial Review of laws. He said in a democracy, laws reflect the will of the majority, raising questions about how morality should be defined in that context. #Judiciary

Hashtags

AI & Law

@ai_and_law · Post #680 · 16.10.2025 г., 07:04

🇺🇸New York Courts Establish Formal AI Use Policy for Judges and Staff New York Unified Court System has issued its first official policy governing the use of generative AI by judges, justices, and court personnel. The interim rules limit the use of AI to approved tools and mandate training for all users. The policy explicitly prohibits entering confidential or privileged information into any generative AI tool that is not operated as a private model under the control of the court system. The document emphasizes that judges and staff remain fully responsible for their work product and must ensure that AI output does not reflect harmful bias, stereotypes, or prejudice. “While AI can enhance productivity, it must be utilized with great care,” said Chief Administrative Judge Joseph Zayas. “It is not designed to replace human judgment, discretion, or decision-making.” #AI#AIethics#Judiciary#AIGovernance

Hong Kong Democracy Movement

@hkdmovement · Post #7992 · 13.05.2025 г., 03:46

#HongKong’s top court plans to appoint New Zealand judge William Young, sparking protests in New Zealand. Critics accuse him of endorsing Hong Kong’s #CCP-controlled judiciary, which has jailed thousands of #politicalprisoners facing unfair trials. Protesters gathered outside Young’s office, demanding he reconsider. When Hong Kong journalists asked for comment, Young replied: “I would not accept appointment unless satisfied it was proper. Apart from that, I have nothing to add and won’t debate my appointment.” His decision raises concerns about legitimizing #Beijing’s judicial control. #Judiciary#CourtOfFinalAppeal#CCPControl #香港#終審法院 計劃任命新西蘭法官楊威廉 ,在紐西蘭引發抗議。批評者指責他為中共控制的司法制度背書 ,該制度已讓數千名 #政治犯 遭受不公正審判。 抗議者在楊威廉的辦公室外集會,要求他重新考慮。香港記者向他提問,他回應: 「除非確信適當,否則不會接受任命。此外,我沒有新內容可補充,也不會討論此事。」 #中共控制