Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
‼️💻The Gardiyum hacking group claimed responsibility for cyber attacks on three major institutions in Bahrain through three separate statements.
🔻 According to the group's claims, over the past 24 hours, operations were carried out against the Khaleeji Bank, the Bahrain Stock Exchange, and Gulf Air airlines, resulting in the systems of these entities being rendered inaccessible for consecutive hours.
🔻 Following these attacks, widespread disruption in service delivery occurred, which, according to Gardiyum, has led to significant damage and extensive dissatisfaction.
#Bahrain
🇧🇭‼️The Public Prosecution of the Al Khalifa regime in Bahrain is demanding the death penalty for who took photos from restricted areas after Iranian attacks!
🔺This authority has accused the detainees of "great treason."
🔺The Ministry of Interior of the Al Khalifa regime arrested 12 Bahraini citizens on charges of filming and sharing videos related to the Iranian armed forces' attacks on U.S. military sites.
#Bahrain
#Iran, #Bahrain: Il Ministero dell'Interno del Bahrain ha annunciato il divieto di manifestazioni e assembramenti in luoghi pubblici per motivi di sicurezza relativi al conflitto scaturitosi nel Golfo.
🇧🇭⛔️ The anti-Iran draft resolution proposed by Bahrain was not adopted
🔹The UN Security Council rejected Bahrain's anti-Iran draft resolution on reopening the Strait of Hormuz, with Russia and China casting vetoes.
🔺 The Bahraini draft resolution initially emphasized the use of all necessary means to reopen the Strait of Hormuz—implying military action—and later, after this clause was removed, focused on defensive and proportionate efforts to ensure maritime security. However, Russia and China used their veto power to block its adoption.
➡️ The representatives of Pakistan and Colombia also refrained from participating in the vote.
#Iran#Bahrain
🇧🇭‼️Seyyed Mohammad al-Mousawi, a Bahraini citizen, was martyred today due to injuries sustained from torture in the prison of the Al Khalifa regime. In the released video, the effects of torture and signs of beating are clearly visible on his face and various parts of his body, and evidence of electric shock is also apparent on his body.
— The martyr was from the Al-Muharraq region and was the son of Seyyed Mohsen al-Mousawi, a cleric from the area, who had previously been imprisoned by the Bahraini regime for over 12 years and was released in 2024 on the occasion of Eid; however, he was recently rearrested by the regime.
➡️ Today, Bahrainis gathered in front the family home of the martyr Seyyed Mohammad al-Mousawi and held a funeral procession for his body while chanting slogans pledging covenant with the martyr.
✍️The Al Khalifa regime has recently arrested and imprisoned a number of Bahraini citizens on false charges of cooperating with Iran or photographing the sites of attacks. The deep-rooted rancor and enmity of the Al Khalifa regime toward Iran and Bahrain’s Shia community are the main reasons behind the arrest and killing of innocent Bahraini citizens and the inhumane actions taken against them.
✍️ Following the heavy strikes by Iran’s armed forces against American bases in the country, Bahrain is on the verge of another popular uprising against the Al Khalifa regime. With the support of Iran and the Shia religious authority, the people can overthrow the puppet Al Khalifa regime.
#Iran#Bahrain
🇮🇷#Iran - 🇧🇭#Bahrain: Footage circulating on Iranian channels show the aftermath of an Iranian missile that has struck Bahrain's Petrolum Company in Sitra moments ago.
🇮🇷#Iran - 🇧🇭#Bahrain: Footage showing an Iranian drone hitting a high-rise building in Bahrain, Manama, earlier today.
(via @Osint613 on X & @theleaflet)