- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I unload (reload) a Python module?
The function reload(moduleName) reloads a previously loaded module (assuming you loaded it with the syntax "importmoduleName" without exiting the script. It is intended for conversational use, where you have edited the source file for a module and want to test it without leaving Python and starting it again. For example,
>>> import mymodule >>> # Edited mymoduleand want to reload it in this script >>> reload(mymodule)
Note that the moduleName is the actual name of the module, not a string containing its name. The python docs state following about reload function:
Python modules’ code is recompiled and the module-level code re-executed, defining a new set of objects which are bound to names in the module’s dictionary. The init function of extension modules is not called a second time. The names in the module namespace are updated to point to any new or changed objects. Other references to the old objects (such as names external to the module) are not rebound to refer to the new objects and must be updated in each namespace where they occur if that is desired.
- How do I find the location of Python module sources?
- What does reload() function do in Python?
- How do I disable log messages from the Requests Python module?
- How I can dynamically import Python module?
- How I can check a Python module version at runtime?
- How do I create a Python namespace?
- How I can install unidecode python module on Linux?
- How do I copy a file in python?
- How do I look inside a Python object?
- How do I do a case insensitive string comparison in Python?
- How do I install Python SciPy?
- How do I calculate the date six months from the current date using the datetime Python module?
- How to write a python module?
- How to install a Python Module?
- How to develop a Python Module?