Python3 learning the Eighth bullet: module Learning one module variable

Source: Internet
Author: User

__name__ variable

Used to determine if the Python file is running as the main program. If the file is imported, the __NAME__ value is its file name, and if the main program, its value is __main__

This is why it is often seen that there are some Python files that have if __name__ = = ' __main__ ' in order to prevent the import of the main program inside the file also run.

__all__ variable

Defines a common interface for a template, such as from OS Import * This means that you can only take advantage of the functions in the __all__ variable, such as the __all__ variable, because there may be a lot of functions, variables and classes that you don't need or want in the template, __all__ Will filter them out. If you do not set the __all__ variable, the import * statement defaults to all global names that do not begin with the underscore.

__doc__ variable

Get a document explanation for a module or function

__file__ variable

The path of the source program (source code) of the module is obtained, and the other method is to find it by Sys.path.

Python3 learning the Eighth bullet: module Learning one module variable

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.