본문 바로가기

Python/Two Scoops of Django

[Two Scoops of Django] 1. Coding Style

* 해당 포스트는 'Two Scoops of Django: Best Practices for Django 1.8 Book by Audrey Roy Greenfeld and Daniel Roy Greenfeld'를 공부하며 적은 기록입니다.

오늘 읽은 부분

1. Coding Style

  • 전 하위 목차

기억해야할 부분

1.1 The Importance of Making Your Code Readable

  • variable name을 생략하지 말자: 모두가 해석하기 쉽게

1.2 PEP8

  • PEP8: official style guide for Python
  • 팁! Flake8(command-line tool for checking coding quality)
  • 한줄에 79-character만 쓰도록 하자

1.3 The Word on Imports

  • Imports가 다음 순서로 그룹화 되어야 한다: Standard library imports, Related third-party imports, Local application or library specific imports

1.4 Use Explicit Relative Imports

  • Exlicit relative imports는 1. module package를 하드코딩하지 않아도 되고, 2. individual module이 이를 감싸고 있는 아키텍처에 꽉 잡혀있지 않아도 되게 한다.
  • "from __future__ import absolute import"

1.5 Avoid Using Import *

1.6.2, 1.6.3 Use Underscores in URL pattern Names/Template Block Names Rather Than Dashes