Как работает функция 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
🌎 The lost Etruscan language remains one of history’s great mysteries. Despite thousands of inscriptions, only parts have been decoded, as Etruscan is unrelated to Latin or Greek. Most surviving texts are funerary or religious, and the longest Etruscan text is on a linen mummy wrapping called the Liber Linteus. ✨
#history⚡#linguistics⚡#etruscan
👉subscribe Interesting Planet
🧩Which of these languages is agglutinative, meaning it builds words by adding simple parts that each express a meaning, rather than using separate words for each meaning?
Options:
Turkish
French
Chinese
English
Take the quiz below to find out
@languagetrivia#theory#linguistics#guess_the_languge
Құрметті Аударгазм клубының мүшелері!
Кейбір пікірлерге байланысты, "орысқұл, арабқұл, қытайқұл" деген ұлт пен болмысты балағайттайтын сөздерді, арна редакторы ретінде жақтырмайтымды ескертіп қоюдың орайы кеп тұр.
Мұнда тілдерді "ғылыми пән" (мүмкінінше) тұрғысында зерделеуге ұмтыламыз.
Тілі бөтен, түрі бөтенді бөлектеп, сабайтын құрал ретінде емес. Ұлтшыл патриот болсаңыз еш қарсылығымыз жоқ, бірақ арна бағыты бөлек, әрі ондай риториканы қолдамайтынымды ескеріп, арна мақсаты мен бағытына аздаған ізет танытуыңызды сұраймын.
Өз басым қазақ тілі ана тілім әрі басым тілім болған соң ғана мазмұн мен мәтінді көбіне қазақша жазамын.
Бұнымды әлдебір тілге қасақана басымдық беру емес, тарихи һәм кәсіби сәйкестік қана деп тапсаңыз игі еді.
Арнада үш тілдің кез келгеніне қатысты мәселені үш тілдің кез келгенінде тіл білімі тұрғысында бейтарап салыстырып, талқылауға болады.
Жаңа қосылған оқырманым, қош келдің, тұрақты оқырманым төзіміңе рақмет.
#тіл_білімі#языкознание#linguistics
Sindhu, Hindu, Indos, India — the modern name “India” ultimately traces back to the Sanskrit Sindhu, the great river named in the Rig‑Veda. As the name moved between languages it shifted: Iranian and some Indic neighbors changed initial s‑ to h‑ (Sindhu → Hindu), Arab and Persian speakers used related forms, and Greek writers rendered the people and land as Indos/India. Medieval European forms (Inde/Indie) circulated in manuscripts and maps, and by the 17th century the modern English name India returned via Latin, Spanish or Portuguese influence.
🌊📜🗺️
[Learn more]
@googlefactss
#etymology#history#linguistics#India#wordorigin
🎓 At the invitation of the Chair of Linguistics and Professional Communication in Foreign Languages at Ural Federal University (URFU), the Office of the Honorary Consul of South Africa in Yekaterinburg joined the graduation ceremony for this year’s linguists, translators, and language educators.
📚 As a token of appreciation, we presented the Chair with Jim Is Tired of Jo'burg by Mzuvukile Maqetuka, published last year by the URFU Publishing House and translated into Russian by Dr. Dmitry Pobedash, a faculty member of the Chair.
🤝 Also, we explored possible areas of cooperation for the upcoming academic year together with Dr. Maria Ilyushkina, Head of the Chair.
#URFU#Education#SouthAfrica#Translation#Linguistics#CulturalDialogue
The staff of the Honorary Consul's office gave a presentation on the Republic of South Africa and the role of Honorary Consul Sergey Mazurkevich to students in the Fundamental and Applied Linguistics and Roman-and-German Philology programs at the Department of Philology at Ural Federal University (URFU).
During the meeting, students had the opportunity to ask questions. After the presentation, we discussed potential avenues for further collaboration with Dr. Anna Plotnikova, Head of the Department.
#education#Yekaterinburg#URFU#Linguistics#Philology#SouthAfrica#HonoraryConsul#Mazurkevich
Snowclones are versatile phrase templates where key words can be swapped to create new, humorous meanings—like linguistic Mad Libs. Coined by linguists Geoffrey K. Pullum and Glen Whitman in 2004, they capture overused, customizable clichés popular in media and memes. Examples include “X is the new Y” or “I, for one, welcome our new X overlords.” They’re a fun way to remix language and culture. 🗣️🎭
Here’s a fresh snowclone to try out:
“X: Because sometimes, Y just isn’t enough.”
Examples:
- “Coffee: Because sometimes, sleep just isn’t enough.” ☕😴
- “Books: Because sometimes, reality just isn’t enough.” 📚✨
@googlefactss
#Snowclone#InternetCulture#Linguistics#Memes#LanguageFun