Your SlideShare is downloading. ×
PEP8 and-autopep8 - PyCon APAC 2013 LT
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

PEP8 and-autopep8 - PyCon APAC 2013 LT

468
views

Published on

Published in: Technology

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
468
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
1
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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