Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
Tata Power Renewable Energy Limited (TPREL) received board approval to invest ₹6,500 crore to establish a 10 GW photovoltaic ingot and wafer manufacturing facility. The project will be developed in two phases of 5 GW each, likely at a greenfield site in Nellore, Andhra Pradesh, with an estimated payback period of five years. This strategic expansion into upstream manufacturing allows Tata Power to achieve backward integration, significantly reducing reliance on Chinese imports while aligning with India’s ALMM framework to strengthen the domestic solar supply chain.
Source
#MakeInindia#solar
Andhra Pradesh Chief Minister N Chandrababu Naidu will lay the foundation stone for ReNew Energy Global plc's Rs 5,400 crore solar manufacturing facility in Anakapalli district. This 6 GW solar ingot and wafer unit marks a significant step in India's push for domestic clean energy manufacturing and energy security, aligning with the state's Integrated Clean Energy Policy 2024
Source
#MakeInindia#solar
🌎 Pluto, once called the ninth planet, orbits in the distant Kuiper Belt and takes about 248 Earth years to complete one orbit around the Sun. ✨
#planets⚡#astronomy⚡#solar-system
👉subscribe Interesting Planet
👉more Channels
🌎 Jupiter’s Great Red Spot is a giant storm larger than Earth and has been raging for at least 350 years, swirling powerful winds nonstop across the planet’s atmosphere. ✨
#planets⚡#astronomy⚡#solar
👉subscribe Interesting Planet
🌍 On rare occasions, the aurora can be seen far from the poles, reaching as far south as Texas or southern Europe during strong solar storms. Their shifting shapes can move faster than a cheetah runs. ✨
#aurora⚡#atmosphere⚡#solar⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Earth travels around the Sun at nearly 30 kilometers per second. This speedy journey means our planet covers more than 940 million kilometers every year as it orbits through space. ✨
#Earth⚡#orbit⚡#solar⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
Japan is home to 73 of world's 100 largest floating #solar plants they prevent water evaporating, and help secure reservoirs in water-stressed countries. - #Japan#Naturehttps://twitter.com/i/status/1391177362927198211@LovelyNature
Japan is home to 73 of world's 100 largest floating #solar plants they prevent water evaporating, and help secure reservoirs in water-stressed countries. - #Japan#Naturehttps://twitter.com/i/status/1391177362927198211@OnlineEducation10
🪐 NASA and ESA are collaborating on future missions to develop solar sail technology—a method that harnesses sunlight for propulsion—to power lightweight spacecraft toward nearby stars like Alpha Centauri. Unlike rockets, solar sails use the gentle push of photons (tiny particles of light) from the Sun to gradually accelerate, making it possible for small probes to reach interstellar space without carrying any fuel onboard. ✨
#spaceships⚡#interstellar⚡#solar⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels