Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
On July 18, 1898, Marie and Pierre Curie discovered polonium, named after Marie’s homeland, Poland. On December 26, 1898, they announced the discovery of radium, with help from Gustave Bémont. These were two new chemical elements that helped scientists learn more about radioactivity. ⚛️
[Source]
@googlefactss
#MarieCurie#Polonium#Radium#ScienceHistory#Radioactivity
Radioactive scientist? Think of a woman.🩻
Let’s talk about the woman, the myth, the legend—Marie Curie. She didn’t just break through ceilings; she melted them with radioactive elements she discovered herself.
Born Maria Skłodowska in Warsaw in 1867, Marie faced financial hardship early on. But with a prodigious memory and relentless drive, she moved to Paris to study at the Sorbonne. There, she wasn’t just a student, she connected with top physicists like Jean Perrin and eventually met her scientific partner in crime, Pierre Curie. Their partnership wasn’t just a marriage; it was a research powerhouse.
As she was working in the lab, Marie noticed something strange: the mineral pitchblende was more radioactive than pure uranium. How could that happen? Apparently, it contained a tiny amount of some unknown, extremely active element. Pierre joined the hunt, and together they discovered two brand new elements: Polonium (named after her beloved homeland, Poland) and Radium.
While Pierre studied the radiation, Marie did the heavy lifting—literally. She isolated pure metallic radium, with a little help from chemist André-Louis Debierne.
When World War I erupted, Marie didn’t hide in a lab. She pioneered mobile X-ray units, famously called “Les Petites Curies.” These were ordinary cars fitted with X-ray apparatus and driven right to the front lines. She personally secured funding, trained medics, and helped examine over one million wounded soldiers. She essentially brought X-rays to the battlefield and made them an essential medical tool.
….
Swipe through posts to explore the legacy Marie left behind!⚡️
#peopleinstemseries#womeninstem#mariecurie#radioactive#radiumgirls