Using the reload function in Python

Source: Internet
Author: User

This article and we share the main is python in the use of reload functions related content, come to see it, hope to learn Python to help you. The reload function uses the module name instead of the variable name, that is, when you change the name, it also loads the original name. When reload is used, the module is recompiled and the new module replaces the original module. If the previous instance created from this module is still implemented using the old module. In particular, names that are loaded with the From-import statement are not updated. Example: # file:builtin-reload-example-1.py fromImpImportReloadImportHelloReload(hello)Reload(hello) output is as follows: = = = restart:d:/work/csdn/python_game1/example/builtin-reload-example-1.py ===hello again, and welcome to The Showhello again, and welcome to the Showhello again, and welcome to the show>>> here helo.py code as follows: print (' Hello AG Ain andWelcome toThe show ') 1. If the module is syntactically correct, but fails during initialization, the import process does not correctly bind the module's name to the symbol table. At this point, the module must be loaded with the import () function before the module can be reloaded. 2. Reloading the module does not delete the original old version of the module in the symbol table of the registration entries. 3. If a module takes advantage of the From ... Import ... Way to import objects from another module, the reload () function does not redefine the imported objects, you can take advantage of the import ... form to avoid this problem. 4. The Reload module that provides the class does not affect any of the saved instances of the provided class---the saved instance will continue to use the original method definition, only the new instance of the class uses the new format. This principle also applies to derived classes. Source: Large slope 3D software development

Using the reload function in Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.