LoginSignup
0
1

More than 3 years have passed since last update.

「PEP8 online check」をやってみた。実行例

Last updated at Posted at 2021-03-07

SOで「関数名と変数名を大文字で始めたくはありませんが、」と指摘をうけたので、「PEP8 online check」をやってみた。
エディタで、pep8するのが、普通かも。
「pycodestyle」と言うのが、正しいですか?

(参考)「素因数分解を約数にする。ループの仕方を教えて下さい。」
https://ja.stackoverflow.com/questions/74430/%e7%b4%a0%e5%9b%a0%e6%95%b0%e5%88%86%e8%a7%a3%e3%82%92%e7%b4%84%e6%95%b0%e3%81%ab%e3%81%99%e3%82%8b-%e3%83%ab%e3%83%bc%e3%83%97%e3%81%ae%e4%bb%95%e6%96%b9%e3%82%92%e6%95%99%e3%81%88%e3%81%a6%e4%b8%8b%e3%81%95%e3%81%84

「PEP8 online check」実行結果

(参考)
http://pep8online.com/
(参考)行番号は、onlineAwkで出力しています。
https://awk.js.org/
'{print NR,$0}'

1 from sympy import *
2 import itertools
3 var('My_Yakusu')
4 def My_SoinsuToYakuSu(My_factorint):
5     k_list = list(My_factorint.keys())
6     v_list = list(My_factorint.values())
7     My_list=list(itertools.product(
8                  list(range(v_list[0]+1)),
9                  list(range(v_list[1]+1)),
10                  list(range(v_list[2]+1))))
11     My_Yakusu = []
12     for i in range(len(My_list)):
13         My_Yakusu.append(  k_list[0] ** My_list[i][0] \
14                          * k_list[1] ** My_list[i][1] \
15                          * k_list[2] ** My_list[i][2] )
16     return sorted(My_Yakusu)
17 
18 print("#sy 90-約数     ",divisors(90, generator=False))
19 print("#sy 90-素因数分解",factorint(90))
20 print("#my 90-約数     ",My_SoinsuToYakuSu(factorint(90)))
21 print("")
22 print("#630は、間違っています。")
23 print("#sy630-約数     ",divisors(630, generator=False))
24 print("#sy630-素因数分解",factorint(630))
25 print("#my630-約数     ",My_SoinsuToYakuSu(factorint(630)))
26 
27 #sy 90-約数      [1, 2, 3, 5, 6, 9, 10, 15, 18, 30, 45, 90]
28 #sy 90-素因数分解 {2: 1, 3: 2, 5: 1}
29 #my 90-約数      [1, 2, 3, 5, 6, 9, 10, 15, 18, 30, 45, 90]
30 
31 #630は、間違っています。
32 #sy630-約数      [1, 2, 3, 5, 6, 7, 9, 10, 14, 15, 18, 21, 30, 35, 42, 45, 63, 70, 90, 105, 126, 210, 315, 630]
33 #sy630-素因数分解 {2: 1, 3: 2, 5: 1, 7: 1}
34 #my630-約数      [1, 2, 3, 5, 6, 9, 10, 15, 18, 30, 45, 90]

Check nresults
以下はpythonソースでないですが、「```python」としています。

Code    Line    Column  Text
E302    4   1   expected 2 blank lines, found 0
E225    7   12  missing whitespace around operator
E201    13  26  whitespace after '('
E502    13  55  the backslash is redundant between brackets
E128    14  26  continuation line under-indented for visual indent
E502    14  55  the backslash is redundant between brackets
E128    15  26  continuation line under-indented for visual indent
E202    15  54  whitespace before ')'
E231    18  27  missing whitespace after ','
E231    19  31  missing whitespace after ','
E231    20  27  missing whitespace after ','
E231    23  27  missing whitespace after ','
E231    24  31  missing whitespace after ','
E231    25  27  missing whitespace after ','
E265    27  1   block comment should start with '# '
E265    28  1   block comment should start with '# '
E265    29  1   block comment should start with '# '
E265    31  1   block comment should start with '# '
E265    32  1   block comment should start with '# '
E501    32  80  line too long (109 > 79 characters)
E265    33  1   block comment should start with '# '
E265    34  1   block comment should start with '# '
W292    35  7   no newline at end of file
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