Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в Python в модуле re.
Чтобы указать флаг для компилятора нам надо указать его после передаваемой строки. Например, добавляем флаг для игнорирования переноса строки.
pattern = re.compile(r"(\w+)+")
words = pattern.search(text, re.DOTALL)
А как указать несколько флагов? Ведь явно будут ситуации когда нам потребуется больше одного. Кто читал посты по битовые операторы уже понял как.
pattern.search(text, re.DOTALL | re.VERBOSE)
А теперь смотрим исходники, что находится в этих атрибутах?
Не удивительно, степени двойки. Почему? Потому что каждое следующее значение это сдвиг единицы влево.
>>> for n in [1, 2, 4, 8, 16, 32, 64, 128, 256]:
>>>
print(bin(n))
0b1
0b10
0b100
0b1000
0b10000
0b100000
0b1000000
0b10000000
0b100000000
Чтобы было понятней, давайте напишем тоже самое но иначе, добавим ведущие нули:
000000001
000000010
000000100
000001000
000010000
000100000
001000000
010000000
100000000
Не понятно что тут происходит? Читай три поста про битовые операторы начиная с этого ➡️https://t.me/pythonotes/45
В общем, это пример применения побитовых операций в самом Python.
Теперь вы знаете Python еще немного лучше)
#tricks#regex#libs
年屆77歲的香港傳媒大亨黎智英,其牢獄歲月於周五(7日)踏入第1500日。他是許多被中國共產黨在香港監禁的政治犯之一,法治已完全消失。
英國人權組織《香港監察》創辦人羅傑斯呼籲全球領導人營救黎智英,並敦促教宗方濟各關注其信仰權利,釋放這位虔誠的天主教徒。
#黎智英#JimmyLai#蘋果日報#新聞自由#人權
At 77, Hong Kong media mogul Jimmy Lai has spent 1,500 days in prison as of Friday (7th). He is one of many political prisoners jailed by the CCP in Hong Kong, where the rule of law has vanished.
Benedict Rogers of Hong Kong Watch calls on global leaders to rescue Lai and urges Pope Francis to advocate for his release, considering his rights as a devout Catholic.
#JimmyLai#AppleDaily#FreePress#HumanRights
Trump’s War on the Press: Lawsuits, Payoffs, and Intimidation
President Trump has escalated his legal campaign against the media, settling some suits, losing others, and keeping a handful of major outlets in his crosshairs. ABC and CBS both coughed up millions—$15 million and $16 million respectively—to avoid protracted battles, with settlements coming suspiciously close to big regulatory approvals for their parent companies. Critics say these payouts are less about justice and more about buying peace with a president who wields the threat of retaliation like a club.
But the fight isn’t over. Trump’s lawsuits against The New York Times, The Wall Street Journal, and the BBC are still grinding through the courts, with claims ranging from defamation to election interference. Legal experts widely agree that most of these cases are weak, but media owners are wary: refusing to settle could mean more lawsuits, regulatory headaches, or even targeted attacks from the administration.
“This is merely an attempt to stifle independent reporting and generate PR attention, but The New York Times will not be deterred by intimidation tactics.”
— NYT spokesperson
Trump’s playbook is clear: sue, threaten, and settle. The message to the press is unmistakable—cross the president, and you might pay dearly, whether in court or at the negotiating table. But as the lawsuits pile up, the question remains: is this about protecting his reputation, or about silencing the watchdogs?
Who’s really afraid of whom?
#Trump#media#lawsuit#freePress#NYT#WSJ#BBC#intimidation
📱American Оbserver - Stay up to date on all important events
🇺🇸