Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
PEP 8 and autopep8 PyCon APAC 2013 LT / 2013.09.15 Hideo Hattori
Slide 2
Slide 2 text
whoami C/Python/Zsh My Python Projects , , , ... code on , @hhatto pgmagick otamapy genzshcomp meow Github Bitbucket
Slide 3
Slide 3 text
PEP 8 coding conventions for the Python code Nc”úùk1 Õúß Õc v ”c v göpvz̈v©–− 2013.08.01 •ò&\©¤ http://www.python.org/dev/peps/pep- 0008/
Slide 4
Slide 4 text
PEP 8 modernisation 1 m¤ß”5ðcv •9¡−l¡ ׳•9¡−l¡ Python1.5.2 •9¡−l¡w£Œ\©–¤ß Python2/3 •9¡−l¡wûl\©¤ß http://hg.python.org/peps/rev/fb24c80e9afb
Slide 5
Slide 5 text
About autopep8 simple command-line tool automatic formatting for Python Code require v0.9.4 (2013.09.08) pep8 $ pip install autopep8
Slide 6
Slide 6 text
For Example invalid PEP 8 code import sys, os n = True if n != None: print("none") def f(x): return 2 * x
Slide 7
Slide 7 text
Output Auto-Formatting Code $ autopep8 invalid.py import sys import os n = True if n != None: print("none") def f(x): return 2 * x
Slide 8
Slide 8 text
Aggressive $ autopep8 -a invalid.py import sys import os n = True if n is not None: print("none") def f(x): return 2 * x
Slide 9
Slide 9 text
Print Diff $ autopep8 -d invalid.py --- original/invalid.py +++ fixed/invalid.py @@ -1,7 +1,10 @@ -import sys, os +import sys +import os n = True if n != None: print("none") -def f(x): return 2 * x + +def f(x): + return 2 * x
Slide 10
Slide 10 text
Other Feature ignore/select errors max-line recursive/jobs
Slide 11
Slide 11 text
ofiØ#”O •PEP 8 ³
Slide 12
Slide 12 text
⁄¿autopep8 ³³›–Æ–z“\o
Slide 13
Slide 13 text
https://github.com/hhatto/autopep8
Slide 14
Slide 14 text
Thank you