質問するログイン新規登録

回答編集履歴

2

修正

2019/07/04 07:45

投稿

LouiS0616
LouiS0616

スコア35678

answer CHANGED
@@ -9,7 +9,7 @@
9
9
  pycodestyle先生にもお伺いを立ててみました。
10
10
  ```
11
11
  >type sample1.py
12
- print(1 in range(3))
12
+ print(1 not in range(3))
13
13
 
14
14
  >python -m pycodestyle sample1.py
15
15
 

1

追記

2019/07/04 07:45

投稿

LouiS0616
LouiS0616

スコア35678

answer CHANGED
@@ -3,4 +3,21 @@
3
3
 
4
4
  > Use is not operator rather than not ... is. While both expressions are functionally identical, the former is more readable and preferred.
5
5
 
6
- **引用元**: [PEP 8 -- Style Guide for Python Code | Python.org](https://www.python.org/dev/peps/pep-0008/#programming-recommendations)
6
+ **引用元**: [PEP 8 -- Style Guide for Python Code | Python.org](https://www.python.org/dev/peps/pep-0008/#programming-recommendations)
7
+
8
+ ---
9
+ pycodestyle先生にもお伺いを立ててみました。
10
+ ```
11
+ >type sample1.py
12
+ print(1 in range(3))
13
+
14
+ >python -m pycodestyle sample1.py
15
+
16
+ >type sample2.py
17
+ print(not 1 in range(3))
18
+
19
+ >python -m pycodestyle sample2.py
20
+ sample2.py:1:7: E713 test for membership should be 'not in'
21
+ ```
22
+
23
+ not inを使え、とのことです。