Help us understand the problem. What is going on with this article?

python入門[import] 「from relative_module import identifier」 とか

目的

import文に関して
 import モジュール
という構文の意識が強くて、
 from AA import BBBB
という構文で、BBBBがモジュールでないのが、どうにも、気持ち悪かった。。。
納得を求めて、調査したが、
結局、以下の記載が一番すっきりしていたので、メモ。

https://docs.python.org/ja/3/reference/simple_stmts.html#grammar-token-import-stmt

import statement

import statementの説明は、以下。
import moduleは、ほんの一例に過ぎないと読める。
各々のケースの処理内容も説明されているので、更に、納得。

(出典:https://docs.python.org/ja/3/reference/simple_stmts.html#grammar-token-import-stmt)

import_stmt     ::=  "import" module ["as" identifier] ("," module ["as" identifier])*
                     | "from" relative_module "import" identifier ["as" identifier]
                     ("," identifier ["as" identifier])*
                     | "from" relative_module "import" "(" identifier ["as" identifier]
                     ("," identifier ["as" identifier])* [","] ")"
                     | "from" module "import" "*"
module          ::=  (identifier ".")* identifier
relative_module ::=  "."* module | "."+

from.png

まとめ

「docs.python.org/ja/3/reference」が、一番いいときもあると感じた。

関連(本人)

pythonをストレスなく使う!(結局docs.python.orgのreferenceが納得感が高い気が、、、)
英語と日本語、両方使ってPythonを丁寧に学ぶ。

今後

何かあれば、追記します。
コメントなどあれば、お願いします:candy:

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away