Skip to content

Instantly share code, notes, and snippets.

@alastair
Created March 21, 2017 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alastair/592844c648ef0ad59b83c2ebf9912a5e to your computer and use it in GitHub Desktop.
Save alastair/592844c648ef0ad59b83c2ebf9912a5e to your computer and use it in GitHub Desktop.

Common style mistakes

This section shouldn't act as a replacement for the style rules listed above in PEP-8, however it shows a number of common cases where care should be taken.

def myfunction(arga, argb=None):
    """ Function documentation. """     # Always use triple double-quotes for docstrings
    data = {                            # If a dictionary doesn't fit on one line, split like this
        "first": 1,                     # space after : but not before
        "second": 2,                    # Comma on the last item of a dictionary or list
    }                                   # Align with the beginning of the variable name
    astr = "Some data"                  # Always use double quotes for strings 
    bstr = 'He said "quote with care"'  # ... unless you need to include them in a string
    arga += 1
    if arga > 1:
        print("Big argument")           # Python3-style print functions


def anotherfunction():                  # 2 newlines between functions in a module
    myfunction(1, argb=4)               # Space after ,; no spaces around =
Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Copy link

ghost commented Mar 21, 2017

Hi. This is a Test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment