Python Modules and Packages

Source: Internet
Author: User

Module overview

If the module is a logical way to organize Python code, then the file is the method of organizing the module on the physical layer.
Therefore, * * A file is considered a standalone module, and a module can also be viewed as a file. The file name of the module is modulo
The name of the block plus the extension. py. Unlike other languages in which you can import classes (Class), you are importing module or module properties in Python * *.

Module name space

A namespace is a relational mapping of names to objects.

Import Module Import Module overall

Way One

import module1import module2...import moduleN

Way Two

import module1[, module2[,... moduleN]]
Import module properties (from ... import ...)

Calling From-import can import the name into the current namespace, which means that you do not need to use the attribute/period property identifier to access the module's identifier. For example, you would need to access the Var name in the modules module that was imported like this:

From module import name1[, name2[,... Namen]]

Renaming a module or property after importing
...............
Package

Package is a hierarchical file directory structure, the module corresponds to a single file, the package corresponds to a directory. As with classes and modules, the package also uses the period property to identify the elements that are accessing them. Import the modules in the package using standard import and From-import statements.

Python Modules and Packages

Related Article

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.