From 75d856fa26485d4f7a130397c3acaf8516bad156 Mon Sep 17 00:00:00 2001 From: Ken Nguyen <30739815+kennguyen01@users.noreply.github.com> Date: Sat, 27 Oct 2018 23:13:15 -0400 Subject: [PATCH] Added PEP8 convention (#20168) --- guide/english/python/code-blocks-and-indentation/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/guide/english/python/code-blocks-and-indentation/index.md b/guide/english/python/code-blocks-and-indentation/index.md index 252bbe3355..601a79432d 100644 --- a/guide/english/python/code-blocks-and-indentation/index.md +++ b/guide/english/python/code-blocks-and-indentation/index.md @@ -1,7 +1,9 @@ --- title: Python Code Blocks and Indentation --- -It is generally good practice for you not to mix tabs and spaces when coding in Python. Doing this can possibly cause a ```TabError```, and your program will crash. Be consistent when you code - choose either to indent using tabs or spaces and follow your chosen convention throughout your program. +It is generally good practice for you not to mix tabs and spaces when coding in Python. Doing this can possibly cause a ```TabError```, and your program will crash. [PEP8](https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces) recommends spaces as the preferred method of indentation. This is because in Python 3, mixing tabs and spaces are not allowed. + +That being said, it is a good idea to follow the formatting convention that your team agreed to use. Be consistent when you code - choose either to indent using tabs or spaces and follow your chosen convention throughout your program. Many code editors and IDEs allow you to specify how many spaces you want in a tab to ensure consistency. #### Code Blocks and Indentation One of the most distinctive features of Python is its use of indentation to mark blocks of code. Consider the if-statement from our simple password-checking program: