Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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 Trump administration has quietly removed a Pride flag from the Stonewall National Monument in Manhattan.
The flag’s removal follows new federal guidance issued by the Department of the Interior on Jan. 21 that restricts the display of unauthorized flags at National Park Service sites. Under the order, only U.S. flags or congressionally authorized flags may be raised on NPS flagpoles. Manhattan borough president Brad Hoylman-Sigal told The New York Times the Trump administration’s order directly led to the Pride flag’s disappearance from the Greenwich Village site, which marks the birthplace of the modern LGBTQ rights movement. Stonewall became the nation’s first federally recognized LGBTQ historic site in 2016, commemorating the 1969 police raid that sparked days of protests and helped launch the gay rights movement. Hoylman-Sigal said he and other local officials plan to raise the Pride flag again on Thursday, despite potential backlash. “We may be prevented from doing so,” he told the outlet, “but if we don’t seize this moment, and this outrage, I think we’ll let down generations of queer activists.” The Daily Beast has reached out to Brad Hoylman-Sigal for comment.
#Trump#LGBTQ
👂More on Trump's Ear ⚠️
Trump announced that he was reopening psychiatric clinics that the Democrats had closed out of tolerance for psychos.
This is a very bold move, given the fact that a huge percentage of Americans today are obviously mentally ill. Trump is leading the way to gradually send transgender and LGBTQ+ there. This is a subproject of MAGA called MAHA - Let's Make America Healthy Again. Trump starts with psychiatry, as this is where the cases are most neglected.
#Trump#Health#LGBTQ+
👂More on Trump's Ear ⚠️
🏳🌈🇺🇦"When a clown moves into a palace he does NOT become a King. The palace becomes a CIRCUS."
Nothing to see here. That's just bloody clown and a drag queen Zelensky is dancing on high hills.
#lgbtq#Ukraine#Zelenskyy
Share and subscribe @american_majority
🇺🇦🏳🌈🏳⚧A Ukrainian LGBT+ recruitment campaign video turned to be a video from the campaign for gay marriage in the UK in 2012.
🇺🇸🏳🌈At the same time the U.S. Army is running a recruitment campaign targeted to Generation Z that featured cartoons of real soldiers who were either females, racial minorities or even "raised by two moms".
#Ukraine#army#lgbtq
@american_majority
美国同性婚姻占各州人口比例
楼主还注释道 DC 更像是个城市,所以写了 Vermont 是“最高”的州。
在评论里注释了城市的比例,但其实按城市算 DC 也远超其它城市……排除之后,毫不意外三番第一,波特兰和西雅图紧随其后,在传统红州的奥兰多、迈阿密(佛州)和奥斯丁(德州)也名列前茅。
#data#visual#reddit#lgbtq