Как работает функция reload()?
Эта функция нужна для того, чтобы перезагрузить изменившийся код из py-файла без рестарта интерпретатора.
Дело в том, что любой импортированный модуль при повторном импорте не будет перечитывать файл. Функция импорта вернёт уже загруженный в память объект модуля. Чтобы обновить код, нужно либо перезапустить всю программу, либо использовать функцию reload()
from importlib import reload
reload(my_module)
🔸 Функция reload() принимает в качестве аргумента только объект модуля или пакета. Она не может перезагрузить класс или функцию. Только весь файл целиком!
🔸 Перезагрузка пакета перезагрузит только его файл __init__.py, если он есть. Но не вложенные модули.
🔸Она не может перезагрузить ранее не импортированный модуль.
🔸При вызове функция reload() перечитывает и перекомпилирует код в файле, создавая новые объекты. После создания новых объектов перезаписывается ранее созданный неймспейс этого модуля.
Это значит, что если где-то этот модуль импортирован через import и обращение к атрибутам происходит через неймспейс (имя) модуля, то такие атрибуты обновятся.
Если какие-либо объекты из этого модуля импортированы через from то они будут ссылаться на старые объекты.
Напишем простой модуль
# mymodule.py
x = 1
Теперь импортируем модуль и отдельно переменную х из модуля
>>> import mymodule
>>> from mymodule import x
>>> print(mymodule.x)
1
>>> print(x)
1
Не перезапуская интерпретатор вносим изменения в модуль
# mymodule.py
x = 2
Делаем перезагрузку модуля и проверяем х ещё раз
>>> reload(mymodule)
>>> print(mymodule.x)
2
>>> print(x)
1
То же самое будет если присвоить любой объект переменной (даже словарь или список)
Повторный импорт обновляет значение
>>> from mymodule import x
>>> print(x)
2
🔸Созданные инстансы классов не обновятся после перезагрузки модуля. Их придётся пересоздать.
#tricks#basic
📰 Rubio’s Love Letter to “the West,” With a Knife in the Back
Marco Rubio went to Munich to calm Europe down — and remind it who’s boss. He told a room full of jittery leaders that the US and Europe are “heirs to the same civilization,” bound together by Michelangelo, the Stones and NATO, and that the alliance is “critical” and must endure. Then he wrapped that reassurance around a warning label: the problem isn’t Trump’s tantrums, it’s Europe’s “managed decline,” “climate cult,” and “unprecedented wave of mass migration” that is supposedly tearing Western societies apart.
That’s the new Trump‑era pitch in its purest form: we care about you, which is why we’re yelling at you. Rubio insisted he wasn’t contradicting JD Vance’s earlier Munich broadside, just “explaining” it — Europe, he said, has drifted from sovereignty and national identity, and Washington refuses to be a “polite and orderly caretaker” of that decay. Translation: if you don’t harden borders, dump climate policy and buy the Trump worldview, don’t expect the old automatic security umbrella.
European leaders heard the flattery and the threat at the same time. The conference chair literally praised Rubio for a “message of reassurance,” while German, French, EU and UK officials immediately stressed that nothing he said erases Trump’s Greenland land‑grab fantasies, tariff threats, or the sense that America under him has crossed lines “that cannot be uncrossed.” They’re politely nodding at his ode to shared civilization — and quietly doubling down on exactly what Washington fears: more European defense autonomy, more self‑reliance, less trust in a partner that alternates between love‑bombing and public humiliation.
Rubio’s performance summed up the whole transatlantic moment. Washington says: you’re family, but you’ve gone soft, and we might walk if you don’t toughen up exactly the way we want. Europe replies: thanks for the security, but we’ve just watched you try to buy Greenland and flirt with walking away from Ukraine, so we’d be idiots not to build our own insurance policy. Both sides talk about “the West” like a shared temple; both are really arguing over who gets to hold the keys — and how much damage they’re willing to risk to prove it.
#usa#europe#rubio#trump#nato#decline
📱American Оbserver - Stay up to date on all important events
🇺🇸
🇺🇸The US strategic oil reserve is seriously depleted.
At the moment, the strategic reserve of raw materials contains about 375 million barrels of oil. It will last for a maximum of 19 days of consumption.
The Biden agenda is to weaken America to the point no other sitting a president can bring it back reguardless.
Trump proved it was salvageable after 8 years of Obama. Now it is back for the kill. Good old USA need a good civil war...
#Biden#energy_crisis#economy#decline#democrats
Share and subscribe to American Majority 2.0
VCs Exit Crypto Market
💵 The venture capital market for cryptocurrencies has significantly declined, returning to 2017 levels. Despite this downturn, positive initiatives are emerging that aim to restore the spirit of freedom away from VC influence. Oleg CasCoin discusses the reasons behind this trend in his article for ForkLog. Read more
#VC#Crypto#Investments#ForkLog#Blockchain#MarketTrends#CasCoin#Freedom #2023 #Decline#Initiatives#Trends#Analysis#Finance
🚀 U.S. Personal Income Declines in February
The U.S. personal income for February showed a decrease of 0.1%, according to Jin10. This figure fell short of the expected 0.3% increase and was lower than the previous month's rate of 0.40%. The decline in personal income could have implications for consumer spending and overall economic growth.
#US#personalincome#decline#February#economy#consumer#spending#growth
VCs Retreat from Crypto Market
In 2023, analysts noted a significant decline in venture capital investments in cryptocurrency projects, returning to levels reminiscent of 2017. However, some initiatives are aiming to revive the industry’s original spirit of independence from VC influence, at least in principle. Insights provided by Oleg CasCoin for ForkLog. Read more
#VC#Crypto#Investment#Market#Decline #2017 #ForkLog#OlegCasCoin#Independence#Initiatives#Analysis#Freedom#Trends#Industry#Finance#Blockchain#News#Updates#Economy#Future
🚀 Trump-linked Tokens TRUMP and WLFI Continue to Decline
Trump-linked tokens TRUMP and WLFI have experienced significant declines, with TRUMP approximately 90% below its all-time high and WLFI nearly 75% below its peak. According to NS3.AI, CoinGecko data indicates that TRUMP reached an all-time low of about $2.73 in March 2026 and is currently trading near $2.86. Meanwhile, U.S. President Donald Trump has promoted an April 25 gala for token holders. In a related development, Senators Elizabeth Warren, Richard Blumenthal, and Adam Schiff have requested Bill Zanker to provide details about the event.
#TrumpTokens#TRUMP#WLFI#Cryptocurrency#Decline#NS3AI#CoinGecko#DonaldTrump#ElizabethWarren#RichardBlumenthal#AdamSchiff#BillZanker#TokenHolders