TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #205 · 22 јан.

Как работает функция 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

Резултати

Пронајдени 1 слични објави

Пребарај: #specialmilitaryoperation

当前筛选 #specialmilitaryoperation清除筛选
Embassy of Russia in Singapore

@rusembsg · Post #3786 · 21.12.2024 г., 06:20

Results of the Year with President of the Russian Federation Vladimir Putin (Moscow, Kremlin, 19 December 2024) #Year2024HighlightsRussia#VladimirPutin#Outcomes2024 #Economy The economic situation in Russia is generally positive and stable. We are growing in spite of everything, in spite of any external threats or attempts at outside influence. Last year Russia increased its GDP by 3.6 percent, and this year the economy is expected to grow by 3.9 percent, or possibly even four percent. What this means is that our economy will have grown by eight percent over the past two years. <…> In the United States – 5-6 percent, Eurozone – 1 percent. In the EU’s leading economy, Germany – 0 percent. International financial and economic institutions ranked Russia as Europe’s biggest economy in terms of volume, in terms of purchasing power parity, and the world’s fourth largest economy. We are behind China, the United States and India. Last year, Russia surpassed Germany and this year, we left Japan behind. #Sovereignty Russia has become significantly stronger in the past two or three years. We are becoming a truly sovereign country, and we barely depend on anybody. We are capable of firmly standing on our feet when it comes to the economy. We are strengthening our defence capability. The combat readiness of the Russian Armed Forces is the highest in the world today. I assure you it is the highest. #SpecialMilitaryOperation I must say that the situation [in the special military operation zone] is changing radically. Our fighting men are regaining the territory by square kilometers. We are advancing, as we said, towards achieving the priority goals that we outlined at the start of the special military operation. Our troops are fighting heroically in the direct sense of the word. The combat readiness of the Russian Armed Forces is the highest in the world today. #NuclearDoctrine It is not a new doctrine but actual changes. I will name some key aspects. We are talking about some new military hazards that may grow into military threats. They include missile defence systems and some other things that we list. [The document] speaks about increasing the responsibility of non-nuclear states that may participate in an aggression against the Russian Federation alongside the countries that have nuclear weapons. If, like their allies, these countries also pose a threat to our sovereignty and Russia’s existence, then we imply that we have the right to use our nuclear weapons against them [non-nuclear states]. If similar threats are posed to Belarus, our ally and member of the Union State, the Russian Federation will consider these threats as threats to Russia. And we will do everything to ensure the security of Belarus. It is a very important component of the updated nuclear strategy of the Russian Federation. #OreshnikMissile Oreshnik missile system is a new intermediate- and shorter-range system. It can strike targets located 1,000, 1,500, 3,000-plus and up to 5,500 km away. Supposing our system is located 2,000 km away, the missile interceptors on Polish territory would be unable to hit it. It takes time to travel this distance, while our missile needs a few second to start dispensing warheads, and that’s it, the ship has sailed. There is almost no chance of shooting down these missiles. #Syria Russia came to Syria ten years ago to prevent the creation of a terrorist enclave there, like the one that we saw in some other countries, for example, Afghanistan. We have achieved that goal, by and large. Even the groups that were fighting against the Assad regime and the government forces back then have undergone internal changes. The current situation in the Syrian Arab Republic remains challenging. We sincerely hope for peace and stability to be restored. We maintain dialogue with all groups controlling the situation there and with all regional countries. An overwhelming majority of them have expressed interest in retaining our military bases in Syria.