Skip to content

[Style Guide for Python Code] PEP8

visionNoob edited this page Oct 1, 2018 · 1 revision

Contents of table

1. 소개(Introduction)

2. A Foolish Consistency is the Hobgoblin of Little Minds

4. Code Lay-out

4.1. Indentation

Use 4 spaces per indentation level.

4.2. Tabs or Spaces?

4.3. Maximum Line Length

4.4. Should a Line Break Before or After a Binary Operator?

4.5. Blank Lines

4.6. Source File Encoding

4.7. Imports

4.8. Module Level Dunder Names

5. String Quotes

6. Whitespace in Expressions and Statements

6.1 Pet Peeves

6.2 Other Recommendations

7. When to Use Trailing Commas

8. Comments

8.1. Block Comments

8.2. Inline Comments

8.3. Documentation Strings

9. Naming Conventions

9.1. Overriding Principle

9.2. Descriptive: Naming Styles

9.3. Prescriptive: Naming Conventions

9.3.1 Names to Avoid

9.3.2 ASCII Compatibility

9.3.3 Package and Module Names

9.3.4 Class Names

9.3.5 Type Variable Names

9.3.6 Exception Names

9.3.7 Global Variable Names

9.3.8 Function and Variable Names

9.3.9 Function and Method Arguments

9.3.10 Method Names and Instance Variables

9.3.11 Constants

9.3.12 Designing for Inheritance

9.4. Public and Internal Interfaces

10. Programming Recommendations

10.1. Function Annotations

10.2. Variable Annotations

References

[1] PEP 7, Style Guide for C Code, van Rossum
[2] Barry's GNU Mailman style guide http://barry.warsaw.us/software/STYLEGUIDE.txt
[3] Donald Knuth's The TeXBook, pages 195 and 196.
[4] http://www.wikipedia.com/wiki/CamelCase
[5] Typeshed repo https://github.com/python/typeshed
[6] Suggested syntax for Python 2.7 and straddling code https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code

Copyright

This document has been placed in the public domain. Source: https://github.com/python/peps/blob/master/pep-0008.txt

Clone this wiki locally