Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PEP8 and-autopep8 - PyCon APAC 2013 LT

945 views

Published on

Published in: Technology
  • Be the first to comment

PEP8 and-autopep8 - PyCon APAC 2013 LT

  1. 1. PEP 8 and autopep8   PyCon APAC 2013 LT / 2013.09.15  Hideo Hattori
  2. 2. whoami C/Python/Zsh My Python Projects , , , ... code on , @hhatto pgmagick otamapy genzshcomp meow Github Bitbucket
  3. 3. 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/
  4. 4. 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
  5. 5. About autopep8 simple command-line tool automatic formatting for Python Code require v0.9.4 (2013.09.08) pep8 $ pip install autopep8
  6. 6. For Example invalid PEP 8 code import sys, os n = True if n != None: print("none") def f(x): return 2 * x
  7. 7. Output Auto-Formatting Code $ autopep8 invalid.py import sys import os n = True if n != None: print("none") def f(x): return 2 * x
  8. 8. Aggressive $ autopep8 -a invalid.py import sys import os n = True if n is not None: print("none") def f(x): return 2 * x
  9. 9. 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
  10. 10. Other Feature ignore/select errors max-line recursive/jobs
  11. 11. ofiØ#”O •PEP 8³
  12. 12. ⁄¿autopep8³³›–Æ–z“o
  13. 13.   https://github.com/hhatto/autopep8
  14. 14. Thank you

×