Parentheses are used to import python data.

Source: Internet
Author: User

Parentheses are used to import python data.

When importing the Python module, we can use

Import OS

You can also use

From OS import *

Of course, the second method is not recommended. In this way, too many functions in the OS module will be imported, so we will use

From OS import name, getcwd

However, if you want to import a large number of functions, the recommended code style will exceed 80 characters in a line. What should you do.

We have three methods:

First, add a backslash \ at the end of the row \,
Second, each line only imports a part and writes several more lines from

However, this is not recommended by PEP. PEP recommends that the imported modules be enclosed in parentheses by standard grouping.

From OS import (name, getcwd)This method can be divided into multiple rows.

This function is supported from python2.4.

This suggestion can be found in PEP328.

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.