Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
India GST collections hit ₹2.43T in Apr’26 vs ₹2.23T (ex-cess) last year, +8.7% YoY; net GST ₹2.11T, +7.3%. Import-linked GST up 25.8%. Despite tax cuts, higher taxable value signals consumption strength; FY27 Centre target ₹10.2T.
#Economy
Centre to maintain FY27 capex at ₹12.22 lakh crore (+~9% YoY) vs ₹2 lakh crore in FY15. Govt to exit non-strategic sectors to crowd in private investment; LPG imports at ~60% with ~90% via Hormuz flagged as risk. R&D spend at 0.6% of GDP under review. #Economy
🇮🇳🤝🇨🇳 India gives fast track nod for China FDI in seven sectors
“These are capital goods, electronic capital goods, electronic components, polysilicon and ingot wafer, advanced battery components, rare earth permanent magnets, and rare earth processing”
#Economy
https://t.co/w0FYHf2dWh
Invest India brings in $6.1 bn investments across 60 projects in FY26 and It is estimated that India will attract investment worth $90 billion this year.
#Economy
Reliance Industries just posted ₹95,754 crore in annual profit. That is over $10 billion. First Indian company in history to cross that line.
The $10 billion profit club globally has maybe 50 companies. India just put one in it. #Economy
According to April 2026 IMF data, India has slipped to the 6th largest economy, falling behind the UK ($4.26T) with a projected FY27 nominal GDP of $4.15 trillion.
The decline is not due to a reduction in real economic growth, but primarily caused by a weakening Indian Rupee against the US Dollar and a downward revision of nominal GDP following a base-year change in Feb 2026.
#Economy