Python ã® Coding Style ãããã
åçªã§ãããPython ã® Coding Style ã«ã¤ãã¦åèã«ãªããããªãã®ãã¾ã¨ãã¦ã¿ããã¹ãã 主ã«ãã¼ã¹ã¨ãªãPEP8ã®ä»ã«ãåãè¦èãããWebãã¬ã¼ã ã¯ã¼ã¯ã®Coding Styleãåæãã¦ãã¾ãã
PEP 8 Style Guide for Python Code
PEP 8 㯠Pythonãæ¸ãä¸ã§å¤§ä½ã¿ããªãåèã«ããCoding Styleã§ãã以ä¸ã«ããã Coding Styleéã¯ãPEP8 ã«å¾ãããã®ä¸ã§ç¬èªã®Coding Styleãå®ç¾©ãã¦ãããã®ãã»ã¨ãã©ã§ãã
PEP ãåè³ã¨ãã人ã¯ãä¸è¨ã¨ã³ããªã¼ãåèã«ãªãã§ãããã
PEP 257 Docstring Conventions
- http://www.python.org/dev/peps/pep-0257/
- (å訳) http://www.python.jp/doc/contrib/peps/pep-0257.txt
ãã¡ã㯠docstring 㮠表è¨ã«é¢ãã PEP ã§ããPythonã§ã¯ docstringãå©ç¨ãã¦ã¢ã¸ã¥ã¼ã«ã®ãã«ãããé¢æ°ã»ã¯ã©ã¹ã¸ã®ã³ã¡ã³ããæ¸ãäºãæ¨å¥¨ããã¦ãã¾ãããã®docstringãã©ãæ¸ãã¹ããã«ã¤ãã¦ãæ¸ããã¦ãã¾ãã
Google Python Style Guide
- http://google-styleguide.googlecode.com/svn/trunk/pyguide.html
- (å訳) http://works.surgo.jp/translation/pyguide.html
Googleã®åºãã¦ããã¬ã¤ãã§ããpycheckerã®è©±ãå¼æ°ã®defaultå¤ã®è©±ãªã©ãå²ã¨åºç¯ã«åãã§ãã¾ããã¡ãªããããã¡ãªãããæ確ã«è¨è¼ããã¦ããã®ã§ããªããããå¿ è¦ãªã®ãåããããããªã£ã¦ãã¾ãããã¾æ°ã¥ããã®ã¯ããã¾ãçã«vimrcã®è¨å®ãã¤ãã¦ããã§ããã
The Pylons Project | Coding Style and Standards
Pyramid (http://www.pylonsproject.org/projects/pyramid/about) ã¨ãããã¬ã¼ã ã¯ã¼ã¯ã§æåãªãPylonsããã¸ã§ã¯ã(http://www.pylonsproject.org/)ãåºãã¦ããCoding Style ã§ããStyleãã®ãã®ã¯ PEP8 ã«æºæ ãã¦ãã¦ããã®ä» Pylonsããã¸ã§ã¯ãã«è²¢ç®ããããã®ä½æ³ã«ã¤ãã¦ãæ¸ããã¦ãã¾ãã
Styleã¨ã¯å¥ã®è©±ã§ãããã¦ããããã¹ãã«ã¤ãã¦ã®ã¬ã¤ãã©ã¤ã³ãåèã«ãªãã¨æãã¾ããã
Django | Coding style
è¨ããã¨ç¥ãã Webãã¬ã¼ã ã¯ã¼ã¯ Django ã® Coding Styleã§ãããã¡ããPEP8ãåºæ¬ã¨ãã¤ã¤ãmodel, view, templateçã«é¢ããstyleããæ¸ããã¦ãã¾ããæ¥æ¬èªè¨³ã¯ã¡ãã£ã¨è¦ã¤ããã¾ããã§ããã
The Pocoo Style Guide
- http://www.pocoo.org/internal/styleguide/
- http://flask.pocoo.org/docs/styleguide/ â» ä¸ã® pocooã®ã¬ã¤ãã©ã¤ã³ã¨å 容ã¯ä¸ç·ã§ã
- (å訳) http://tokuda109.github.com/flask-docs-ja/styleguide.html
Flask(http://flask.pocoo.org/) ã Werkzeug(http://werkzeug.pocoo.org/) ã Sphinx(http://sphinx.pocoo.org/)ã¨ãã£ããã¬ã¼ã ã¯ã¼ã¯ããã¼ã«ãä½ã£ã¦ãããPocooã¨ããéå£ï¼ã®ææ¡ããCodingStyleã§ãããã¯ãPEP8ããã¼ã¹ã¨ãªã£ã¦ãã¾ããå人çã«ã¯ moduleã®ãããã¼é¨åã®ã³ã¡ã³ãã®æ¸ãæ¹ã¯åèã«ãªãã¾ããã
Zope | Coding Style
åã¯ãã¾ãç¥ããªãã®ã§ãããZope ã¯å¤ããããã ãã¬ã¼ã ã¯ã¼ã¯ã§ãCMSã® Plone (http://plone.org/) ããUbuntuã®éçºçã§ãå©ç¨ãããBTSã®LaunchPad(https://launchpad.net/) ã§ä½¿ããã¦ããäºã§ãæåãããã§ãããã¡ããPEP8ã«æºæ ãã¦ãã¾ããå人çã«ã¯ã# XXXã ãã# BBBãã¨ãã£ãã³ã¡ã³ãã®æ¸ãæ¹ã¯ãåãã¦ç¥ãã¾ããã
TurboGears | Coding Style
ããããã¬ã¼ã ã¯ã¼ã¯ã§PEP8ã«æºæ ãã¦ãã¾ããååã¯çµæ§æããèããäºãããã¾ãããã©ãããå®ç¸¾ãããã®ãã¯ã¡ãã£ã¨åããã¾ããã§ããã
Repoze
Repoze 㯠Zopeã®åã³ã³ãã¼ãã³ããWSGIã¢ããªã§ã使ããããã«ããããã¸ã§ã¯ãã ããã§ããPEP8ã«å¾ã£ã¦ãã¾ããrepoze.who(http://docs.repoze.org/who/1.0/) çã¯æ å¼±ãªåã§ãèããäºãããã¾ãã
Coding Styleçãªãã®ãè¦ã¤ãããªãã£ãã
ã¾ã¨ã
調ã¹ãåã¯ãçµæ§Webã¢ããªãã¬ã¼ã ã¯ã¼ã¯å½ããã¯ç¬èªã®Styleãæ¨å¥¨ãã¦ããããã¦ãã«ãªã¹ãªäºã«ãªã£ã¦ãã±ã¼ã¹ããããã¨æã£ããã§ãããã»ã¨ãã©ãPEP8ã«å¾ã£ã¦ãã¦ãPEPã®å½±é¿åããããªãã¨ãæãã¾ããã
ããã»ãã¨ãhere is the golden rule: Imitate the existing [ãã¬ã¼ã ã¯ã¼ã¯å] code.ãã¨ãæ¸ãã¦ãªãã¦ãããã
ä½ãä»ã«è¯ããããªãã®ããã£ããæãã¦ä¸ãã