Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в 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
#Italia
❗️BREAKING ANSA - Blitz della Presidente del Consiglio Giorgia #Meloni (#FdI|ECR) nel Golfo. La ‘premier’ è appena atterrata a Gedda e nei prossimi giorni incontrerà i principali leader della zona e visiterà #ArabiaSaudita, #Emirati e #Qatar.
Fonti di Palazzo Chigi sottolineano che la missione a sorpresa della premier mira, tra l'altro, al rafforzamento della sicurezza energetica nazionale.
Si tratta della prima visita nella regione da parte di un leader di Ue, G20 e Nato dall'inizio del conflitto. Il Golfo rappresenta infatti una fonte cruciale di petrolio e gas per l'Italia e ha un ruolo determinante nell'andamento dei prezzi energetici globali.
La missione punta anche a rafforzare le relazioni" con queste nazioni del Golfo e "ribadire il sostegno dell'Italia di fronte agli attacchi iraniani, consolidando al contempo un partenariato strategico sempre più solido.
@OsservatorioItaliano
News: #Somaliland leader departs for #UAE, seeks deeper ties as regional stakes rise
Somalia's northwestern breakaway region of Somaliland President Abdirahman Mohamed Abdullahi departed for the United Arab Emirates on Tuesday, leading a high-level delegation that includes cabinet ministers and senior advisers, his office said.
The trip follows a formal invitation from the UAE government, with President Abdirahman Mohamed expected to attend a conference focused on development and intergovernmental cooperation.
Officials said he is also scheduled to hold meetings in #Abu_Dhabi with senior #Emirati leaders to discuss strengthening bilateral relations.
Talks are expected to center on development projects and investment, areas where the UAE has played a significant role in Somaliland's economy. Emirati logistics firm #DP_World has invested about $442 million in the expansion and .....
https://web.facebook.com/AddisstandardEng/posts/pfbid02vruBZ8aULb9h5RjA2RsY29mzkbAHJ12PxaQznHBY1Zrsq9GGTQzzwa8qRMyK9tUal
What #Sudan can teach #Ethiopia as #Eritrea conflict looms
As African leaders gathered at the annual #African_Union summit in #Addis_Abeba last week under the seemingly non-urgent theme of “water sustainability,” there was only passing acknowledgement that “silencing the guns on our continent remains a challenge.”
Yet the cadence of conflict — and the threat of new war — hung low over the horizon. It never felt proximate enough, however, to darken the mood of the festivities.
Ethiopian Prime Minister Abiy Ahmed was keen to show off his clean and modern metropolis, financed and looking like a “mini-me” version of his #Emirati backers in #Dubai. As host of the three-day summit, Abiy’s heads of state guests showed deference by making no mention of his increasingly bellicose calls for sea access — and the indirect threat to Eritrea, its neighbor.
Nor was there talk of Asmara’s response…..
https://web.facebook.com/AddisstandardEng/posts/pfbid0obN5Kafo8UNTY59yKCGZdnA3LrbsDe5ztUgt28cTAUnTpDGbj4njfoj8yHH63sgnl
In un evento online organizzato da The New York Times parla #Netanyahu: "Non abbiamo finito con #Tehran" e #TomBarrack, Ambasciatore #USA in #Turchia parla negli #Emirati: "Abbiamo ancora da vedere in merito a ciò che potrebbe fare #Israele in #Iran".
I recenti attacchi alle raffinerie saudite hanno evidenziato una notevole vulnerabilità delle strutture saudite e posto interrogativi anche sull affidabilità dei sistemi antimissile Patriot – di produzione statunitense – a cui ne è stata affidata la difesa. In questo senso, l’attacco alle raffinerie saudite rappresenta un duro colpo alla credibilità degli Stati Uniti, segnando inoltre un punto di svolta nella guerra dello #Yemen: un conflitto in cui ormai da anni si fronteggiano le forze governative – sostenute da #Arabia Saudita, #Emirati Arabi e #StatiUniti – e i ribelli #Houti sostenuti dall’#Iran. Un conflitto rispetto al quale l’Arabia Saudita non ha, per il momento, ammorbidito la propria linea oltranzista, nonostante le oltre 70.000 vittime già prodotte dal conflitto, la più grave crisi umanitaria attualmente esistente sul pianeta – secondo l’ ONU –, ed un atteggiamento ormai quasi disfattista da parte degli Emirati Arabi. Il mio articolo per l'Atlante geopolitico di Treccani
http://www.treccani.it/magazine/atlante/geopolitica/Il_Vicino_Oriente_dopo_gli_attacchi_alle_raffinerie_saudite.html