- 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
What are common practices for modifying Python modules?
If you are modifying a module and want to test it in the interpreter without having to restart the shell everytime you save that module, you can use the reload(moduleName) function. reload(moduleName) reloads a previously loaded module (assuming you loaded it with the syntax "import moduleName". 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.
>>> import mymodule >>> # Edited mymodule and 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. In Python 3, reload was moved from builtins to imp. So to use reload in Python 3, you'd have to write imp.reload(moduleName) and not just reload(moduleName).
- What are the best practices to organize Python modules?
- What are Python modules for date manipulation?
- What are the best practices for using loops in Python?
- What are the best practices for exception handling in Python?
- What are the best practices for using if statements in Python?
- What are Python coding standards/best practices?
- What are the modules required for CGI programming in Python?
- What are the best practices for committing in Git?
- What are Perl Modules?
- What are the modules available in Python for converting PDF to text?
- What is the convention for structuring Python modules?
- How do I get IntelliJ to recognize common Python modules?
- Where are the python modules stored?