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

Резултати

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

Пребарај: #romantasy

当前筛选 #romantasy清除筛选
Velvet Pages | eLibrary 🥂

@bookslibraryofficial · Post #1268 · 18.05.2025 г., 16:31

📖Title : Fearless ✍️Author : Lauren Roberts ⭐️Rating : 4.22/5 (Goodreads) 📆Published : Apr 08, 2025 ———————————————— Summary:Fearless by Lauren Roberts is the gripping conclusion to The Powerless Trilogy, a young adult romantasy series. The story follows Paedyn Gray, an Ordinary in a world dominated by the powerful Elites, as she returns to the Kingdom of Ilya. Facing a life-altering decision, Paedyn must navigate political intrigue, personal betrayals, and the complexities of love. Her relationship with Kai Azer, an Elite and her former adversary, intensifies amidst the kingdom's turmoil. As Paedyn confronts trials that test her courage and resilience, she challenges societal norms and redefines strength. Roberts weaves a tale of empowerment, loyalty, and the enduring power of love in a fractured world. ———————————————— #fiction#fantasy#romantasy#youngadult@Bookslibraryofficial@free_novellas@the_ancient_library

Velvet Pages | eLibrary 🥂

@bookslibraryofficial · Post #1264 · 18.05.2025 г., 06:46

📖Title : Enigma ✍️Author : RuNyx ⭐️Rating : 3.91/5 (Goodreads) 📆Published : Apr 29, 2025 ———————————————— Summary:Enigma by RuNyx is a steamy dark academia romance that follows Salem Salazar, the black sheep of a wealthy family, as she enters Mortimer University to uncover the truth behind her sister's mysterious death. Obsessed with death and driven by secrets, Salem is soon entangled with Cazimir van der Waal—a chaotic, brooding artist and teaching assistant with a hidden past. Their intense, rivals-to-lovers relationship unfolds amid secret societies, missing girls, and deadly mysteries on campus. As danger closes in, passion ignites between fire and ice. *Enigma* is a twisted, suspenseful tale of obsession, love, and peril set in an academic underworld. ———————————————— #fiction#darkromance#fantasy#romantasy#darkacademia@Bookslibraryofficial@free_novellas@the_ancient_library

Velvet Pages | eLibrary 🥂

@bookslibraryofficial · Post #1473 · 16.11.2025 г., 15:17

📖Title : Blackthorn ✍️Author : J.T. Geissinger ⭐️Rating : 4.03/5 (Goodreads) 📆Published : Nov 04, 2025 ———————————————— Summary:Blackthorn follows Maven Blackthorn as she returns to her haunted hometown after her grandmother’s funeral—only to discover the body has mysteriously vanished. Caught in a generations-old feud between the Blackthorns and the powerful Croft family, Maven is forced to confront Ronan Croft, her first love and the son of her mother’s suspected killer. Their dangerous chemistry resurfaces as whispers of occult rituals, buried secrets, and horrific betrayals emerge. As Maven digs deeper, she uncovers a terrifying truth that threatens everyone she loves. In a town where the dead refuse to rest, love becomes both a weapon and a deadly curse. ———————————————— #romance#gothic#romantasy#fantasy#paranormal@Bookslibraryofficial@free_novellas@eternalmantra