Calls to functions, classes, modules, and packages in Python

Source: Internet
Author: User

At the beginning of the Python stage, most of the calls to functions, classes, modules, and packages are not very clear, and this essay simply explains them.

? (1) function
When the function is well defined, it can be called directly.
For example:def summ (ADD1,ADD2), then can be called directly, namely:Summ ()

(2) class
After a class is defined, it cannot be called directly as a function, but requires an indirect call.

For example:class people, then call,a=people ( object ), after,a.age () wait

(3) module

placing multiple classes under the same PY , such as in model.py , the import model can be called

(4) package

  1. Create a folder under the Site-package folder, such as : Kitchen
  2. other classes of . PYare put in the Kitchen file
  3. in which the __init__.py file is created, an import statement is displayed, such as the file name of the From Omelet (Party omelet Class) omelet.py) Import omelet ( class name ). when programming, direct import Kitchen,kitchen.xxx can be called

    

Calls to functions, classes, modules, and packages in Python

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.