3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

python > link > from __future__ import absolute_import

Last updated at Posted at 2016-10-11

TensorFlowというDeep Learning関連のもので、mnist.pyというpythonコードを学習中。

https://www.tensorflow.org/versions/master/tutorials/mnist/tf/index.html#tensorflow-mechanics-101
そのmnist.pyにある以下の記述について

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

さりんじゃーのプログラミング日記
http://salinger.github.io/python/20140211-future-module/

absolute_import節参照。

Python 3 では相対インポートではなく、絶対インポート優先になる。標準モジュールと同名のモジュールがカレントディレクトリにある場合、Python 2 系ではカレントディレクトリのモジュールが優先されていたので、これを使うことで標準モジュールを意図せず上書きしてしまう可能性がなくなる。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?