Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PyCon APAC 2013 LT

PyCon APAC 2013 LT

PEP 8 and autopep8

Hideo Hattori

September 15, 2013
Tweet

More Decks by Hideo Hattori

Other Decks in Programming

Transcript

  1. whoami C/Python/Zsh My Python Projects , , , ... code

    on , @hhatto pgmagick otamapy genzshcomp meow Github Bitbucket
  2. 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/
  3. About autopep8 simple command-line tool automatic formatting for Python Code

    require v0.9.4 (2013.09.08) pep8 $ pip install autopep8
  4. For Example invalid PEP 8 code import sys, os n

    = True if n != None: print("none") def f(x): return 2 * x
  5. Output Auto-Formatting Code $ autopep8 invalid.py import sys import os

    n = True if n != None: print("none") def f(x): return 2 * x
  6. Aggressive $ autopep8 -a invalid.py import sys import os n

    = True if n is not None: print("none") def f(x): return 2 * x
  7. 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