- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
- Python Advanced Tutorial
- Python - Classes/Objects
- Python - Reg Expressions
- Python - CGI Programming
- Python - Database Access
- Python - Networking
- Python - Sending Email
- Python - Multithreading
- Python - XML Processing
- Python - GUI Programming
- Python - Further Extensions
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).
- Related Articles
- What are the best practices to organize Python modules?
- What are Python modules for date manipulation?
- What are the modules required for CGI programming in Python?
- What are the best Python 2.7 modules for data mining?
- What are the best practices for exception handling in Python?
- What are the best practices for using loops in Python?
- What are the best practices for using if statements in Python?
- What are the most interesting Python modules?
- What are the modules available in Python for converting PDF to text?
- What is the convention for structuring Python modules?
- What are Python coding standards/best practices?
- What are the “best practices” for using import in a Python module?
- How do I get IntelliJ to recognize common Python modules?
- What are Perl Modules?
- What are the best practices for committing in Git?