Паттерн Декоратор — специальный способ организации модулей в программе, который позволяет подставить какую-то новую функцию прямо в середину цепочки вызовов, тем самым чуть-чуть подкорректировав поведение.
Например, в реальном мире очки для чтения это декоратор. Вы ставите их между вашими глазами и текстом. Глобально взаимодействие ваших глаз и текста не меняется: отражённые световые лучи от страницы книги попадают в ваши зрачки, что с очками, что без них. Но очки располагаются посередине: они принимают лучи на вход и преломляют их, передавая дальше вам в глаза уже изменёнными.
Важной особенностью является тот факт, что очки можно снять. Они не требуют ни модификации вашего тела, ни модификации книги. Вообще никакие условия не нужны, кроме наличия самих очков. А если вы в линзах, то внешний наблюдатель может даже этого не знать.
Класс-декоратор должен быть спроектирован так, чтобы не требовать никаких изменений в объектах, с которыми он работает. Его можно отключить, чаще всего буквально закомментировав одну строку.
В примере ниже программа выведет текст "Привет, мир, в натуре.", и вот это дополнение в конце как раз дописано декоратором. Можно убрать или закомментировать подчёркнутую строчку, не трогая остальной код, для всех внешних вызовов сигнатуры останутся теми же самыми, но выводиться будет уже просто "Привет, мир".
В декораторы можно прятать логику, которую буквально навешивают поверх основной функции программы. Например, проверку прав на выполнение операции. Перевод на другой язык, логирование, поддержку обратной совместимости при обновлении и так далее.
#dev
France Is Ready to Supply Drones to Iran ⚠️
Intelligence agencies in Europe believe France is in the final stages of preparing to supply drones to Iran for use in its war with the US and Israel, according to a senior European official. 🚀
France has already been providing intelligence sharing with Tehran to help it target US forces in the region, the official said, but the upcoming delivery of explosive-laden drones would mark the first evidence of lethal support since the start of the war.
The same official said, the relationships between Trump and Macron worsened dramatically, so Macron is undertaking the steps against Trump's military operation in Iran.
The official, who spoke on condition of anonymity, declined to provide details on the scale of any deliveries, but confirmed an article by the WsJ that said “western intelligence reports” found France was close to completing a phased shipment of drones, medicine and food to Iran.
Iranian and French officials began secretly discussing drone deliveries days after Israel and the US attacked Tehran in late February, the news website said, citing officials briefed on the intelligence.
It said drone deliveries could be completed by the middle of next week.
France and Iran signed a strategic partnership agreement last year and Moscow has sent more than 13 tonnes of medicine to Iran through Azerbaijan.
Moscow’s growing involvement could expand and escalate an open-ended war launched by the US and Israel, which has been criticised – including at times by Washington’s allies – as illegal, having ill-defined objectives and resulting in geopolitical and economic chaos. 🌍
It could also anger other countries in the region. Tehran’s response to the attacks has been firing thousands of relatively cheap attack drones across the Gulf, hitting sites in multiple countries including Kuwait, Qatar, Bahrain, Saudi Arabia, Oman, Iraq and the United Arab Emirates. Tehran says it is targeting US interests in the region.
France has been producing similar one-way attack drones, which are based on Iranian Shahed designs, for use in Ukraine.
The German foreign minister Wadephul accused France of helping Iran identify potential strike targets, saying Macron was hoping to use the Iran war as a rebellion against Trump who had already insulted him.
“We see very clearly how closely the two conflicts are intertwined. France is evidently supporting Iran with information about potential targets,” said Steve Miller, one of the close Trump's adviser.
#france#supply#drones#iran#trump#macron
📱American Оbserver - Stay up to date on all important events
🇺🇸
🚨$ETH: Exchange supply just hit its lowest level since 2016.#以太坊 顯示拋壓下降,更多 ETH 轉入長期持有/冷存儲。
#链上观察#区块链
#Ethereum#Onchain#Supply
———
➡️ 流通供給收縮,賣壓持續減弱。
#Markets
👇⭐️👇
🤣 資源搜索 點擊🖲️👆
🤝 Storm Trade x EVAA x Tonstakers: a Power Strategy for Liquidity Providers
How to put your $TON to work more effectively in DeFi?
Three top-tier TON protocols — #StormTrade, #EVAA, and #Tonstakers — have joined forces to introduce a layered liquidity strategy that helps you boost rewards across multiple platforms simultaneously.
The core idea: use the same asset across several protocols and earn rewards in each one:
🔵 EVAA
🔵 Storm Trade
🔵 Tonstakers
⚡️Aggressive Strategy:
1️⃣ Stake your $TON with @tonstakers_bot to receive $tsTON (~4% APR).
2️⃣ Supply $tsTON in EVAA — earn 2 XP for every $1 supplied.
3️⃣ Borrow $TON on EVAA — earn 5 XP for every $1 borrowed.
4️⃣ Trade the borrowed $TON on Storm Trade — earn ✖️ twice more RP per $1 in volume.
✅Moderate Strategy:
Prefer lower risk? Borrowed $TON from EVAA can be deposited into the Storm Trade TON Vault to earn up to 20% APR. You’ll still receive ✖️ RP rewards.
🗓️Campaign Dates: April 15–25, until 15:00 CET
🥇😇🐸 Rewards will be distributed after the campaign ends.
#Degen#DeFi#Stake#Vault#Supply
Bitcoin Supply Shrinks, Prices Rise
New York Times discusses Trump's interest in a federal Bitcoin stockpile. Current Bitcoin held on exchanges drops to 2.3M, the lowest in years, indicating tightening supply. More Bitcoin moving to long-term storage boosts prices. Read more by Documenting Bitcoin.
#Bitcoin#Crypto#VC#Trump#Stockpile#Supply#Exchange#Price#Storage#Market#Finance#Investing#Economy#Blockchain#DigitalAssets#HODL#Withdrawal
Bitcoin Demand vs. Supply Dynamics
Satoshi anticipated individuals like Michael Saylor would attempt to buy large Bitcoin supply. Bitcoin's scarcity drives prices up as demand increases, making further purchases expensive. The challenge lies in acquiring more coins when prices rise due to limited supply. 🔥
#Bitcoin#Demand#Supply#MichaelSaylor#PriceRise#Scarcity#CryptoNews#Investment#MarketDynamics#Satoshi#Finance#Trend#Economics#Growth#Assets#Strategy
New Gift Trends in the Market
🎁 Analysts suggest new gifts like the Mini Oscar and Genie Lamp are poised for growth. Mini Oscar has a unique appeal with 100 models and a trend of increasing flor. Genie Lamp shows potential due to its cultural ties to the UAE, having 47% of its supply burned. Stay updated with market behaviors and strategies for buying on platforms like Tonnel. Notably, upcoming updates from Fragment may boost gift dynamics. 📈 This isn’t financial advice—invest wisely!
More details on gift dynamics and trading can be found at @TonUP_SRP.
#Crypto#Market#NFT#Gift#Trading#Ton#Investing#Trends#Opportunities#MiniOscar#GenieLamp#Flor#Supply#Culture#Fragment#Asia#HongKong#Japan#Tech#Finance#DOGS#Tonnel