======================== Writing Python with PEP8 ======================== PEP 8, sometimes spelled PEP8 or PEP-8, is a document that provides guidelines and best practices on how to write Python code. It was written in 2001 by Guido van Rossum, Barry Warsaw, and Nick Coghlan. The primary focus of PEP 8 is to improve the readability and consistency of Python code. PEP stands for Python Enhancement Proposal, and there are several of them. A PEP is a document that describes new features proposed for Python and documents aspects of Python, like design and style, for the community. Naming Conventions ================== .. list-table:: Naming Styles :widths: 20 60 20 :header-rows: 1 * - Type - Naming Convention - Examples * - Function - Use a lowercase word or words. Separate words by underscores to improve readability. - function, my_function * - Variable - Use a lowercase single letter, word, or words. Separate words with underscores to improve readability. - x, var, my_variable * - Class - Start each word with a capital letter. Do not separate words with underscores. This style is called camel case. - Model, MyClass * - Method - Use a lowercase word or words. Separate words with underscores to improve readability. - class_method, method * - Constant - Use an uppercase single letter, word, or words. Separate words with underscores to improve readability. - CONSTANT, MY_CONSTANT, MY_LONG_CONSTANT * - Module - Use a short, lowercase word or words. Separate words with underscores to improve readability. - module.py, my_module.py * - Package - Use a short, lowercase word or words. Do not separate words with underscores. - package, mypackage https://realpython.com/python-pep8/