0
1

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.

PEP8 > if asDict == True > E712 comparison to True should be 'if cond is True:' or 'if cond:' > is Trueは正しいのだろうか? | ==をisにして動かなくなる例

Last updated at Posted at 2018-03-24
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04 LTS desktop amd64
TensorFlow v1.2.1
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
scipy v0.19.1
geopandas v0.3.0
MATLAB R2017b (Home Edition)
ADDA v.1.3b6
gnustep-gui-runtime v0.24.0-3.1

      if asDict==True:

上記をpep8コマンドでチェックすると

Mie.py:476:16: E712 comparison to True should be 'if cond is True:' or 'if cond:'

isはオブジェクトの同一性の確認だったかと思うが、この場合は==でなくisの方にすべき、というのは正しいのだろうか?

以下を見つけた。
https://github.com/PyCQA/pycodestyle/issues/696

==isに変更して動かなくなる例

answered Sep 25 '13 at 6:50
Martijn Pieters♦

That's because SQLAlchemy filters are one of the few places where == False actually makes sense. Everywhere else you should not use it.

PEP8 E712の通りに変更すると動かなくなる場合もありそう。

link

その他、==isの違いについての記事
https://qiita.com/search?utf8=%E2%9C%93&sort=&q=Python+title%3Ais

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?