When reading the django source code, I found that upper brackets are always added when importing modules, for example:
from django.core.exceptions import (
DisallowedHost, ImproperlyConfigured, RequestDataTooBig,
)
from django.utils.encoding import (
escape_uri_path, force_bytes, force_str, force_text, iri_to_uri,
)
Please tell me from XXX import (XXX, XXX, XXX,) What is the meaning of the brackets when importing the module like this?
This is a coding specification started with PEP 328. When not adding parentheses, you need to add a backslash at the end of the line when breaking the line, as shown below:
Or write each line again
from xxx import yyy
:With parentheses, you can wrap new lines at will inside the parentheses:
See PEP328
Personal understanding:
Equivalent
The syntax looks simpler, and you can tell at a glance which methods are imported from a module. It's also a matter of habit. The benevolent sees benevolence and the wise see wisdom. Personally, it’s OK if it’s comfortable