pep8 and-autopep8 - pycon apac 2013 lt
TRANSCRIPT
PEP 8 and autopep8
PyCon APAC 2013 LT / 2013.09.15 Hideo Hattori
whoami
C/Python/Zsh
My Python Projects
, , , ...
code on ,
@hhatto
pgmagick otamapy genzshcomp meow
Github Bitbucket
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/
PEP 8 modernisation1�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
About autopep8simple command-line tool
automatic formatting for Python Code
require
v0.9.4 (2013.09.08)
pep8
$ pip install autopep8
For Exampleinvalid PEP 8 code
import sys, os
n = Trueif n != None: print("none")
def f(x): return 2 * x
Output Auto-Formatting Code$ autopep8 invalid.py
import sysimport os
n = Trueif n != None: print("none")
def f(x): return 2 * x
Aggressive$ autopep8 -a invalid.py
import sysimport os
n = Trueif n is not None: print("none")
def f(x): return 2 * x
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
Other Featureignore/select errors
max-line
recursive/jobs
ofiØ#”O�•PEP 8³
⁄¿autopep8³³›–Æ–z“\o
https://github.com/hhatto/autopep8
Thank you