Top "Pep8" questions

Coding conventions and style guidelines for Python.

How to prevent "too broad exception" in this case?

I have a list of functions that may fail and, if one fails, I don't want the script to stop, …

python exception pep8
Should I always specify an exception type in `except` statements?

When using PyCharm IDE the use of except: without an exception type triggers a reminder from the IDE that this …

python exception pep8
PyCharm shows "PEP8: expected 2 blank lines, found 1"

Consider the following code: def add_function(a, b): c = str(a) + b print "c is %s" % c def add_…

python-2.7 pycharm pep8
Tool to convert Python code to be PEP8 compliant

I know there are tools which validate whether your Python code is compliant with PEP8, for example there is both …

python coding-style pep8
How to disable a pep8 error in a specific file?

I tried with #:PEP8 -E223 or # pep8: disable=E223 I thought the second would work but doesn't seems to work. …

python pep8
What's the correct way to sort Python `import x` and `from x import y` statements?

The python style guide suggests to group imports like this: Imports should be grouped in the following order: standard library …

python coding-style python-import pep8
Chained method calls indentation style in Python

From reading PEP-8, I get it that you should put the closing parenthesis on the same line as the last …

python django coding-style pep8
Triple-double quote v.s. Double quote

What is the preferred way to write Python doc string? """ or " In the book Dive Into Python, the author provides …

python pep8 quote docstring pep
Line is too long. Django PEP8

PEP8 info: models.py:10:80: E501 line too long (83 > 79 characters) Models.py: field = TreeForeignKey('self', null=True, blank=True, related_…

python django pep8
Python function argument list formatting

What is the best way to format following piece of code accordingly to PEP8: oauth_request = oauth.OAuthRequest.from_consumer_…

python formatting indentation pep8