[Python basics] things about packages, classes, modules

Source: Internet
Author: User

Reprint Please specify source: http://www.cnblogs.com/codefish/p/5032753.html

Before I understand Python's package, class, and module, I've been referring to him as a dll,c# class, a reference to the namespace, which is actually different from C #, and we'll look at these units from a macro perspective.

One, class

The definition of a class appears in each language, and is almost the smallest packaging unit in OOP, allowing for higher reuse

Two, module

We know that in C # if a new folder is created, and then any class file is added under that folder, the default is to name it this way

folder. Class Name

In this way, all the classes under a folder are encapsulated under a namespace, which is easy to reuse, and the modules are similar, with a single file as a module, referenced by humans as the module name when other landlord references

In summary, each file ending with a. PY is a module (moudle)

Three, Package

In the upper layer of the namespace, which is the DLL assembly, which encapsulates the class text more than one layer, Python uses a folder containing __init__.py to specialize the folder into a package

The package here is the aggregation of modules, wrapped in the same folder.

Four, other

Some students notice two different kinds of grammar when quoting.

__author__ ' Bruce '  from Import darkred Import Humans if __name__ ' __main__ ' :     = darkred ()    dark_red.printinfo ()    Pass

If you look at the subdivision point, you will see: From Color.Red, the general from behind is directly followed by the inclusion of the upper space, and import can only follow a level of space.

Reprint Please specify source: http://www.cnblogs.com/codefish/p/5032753.html

[Python basics] things about packages, classes, modules

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.