Matching PEP8 style with long one line for loop I'm working with Python 2.7.5 and I'm trying to make it match the PEP8 coding style.  I have a few one line for loops but the issue is that they are each above 80 characters in length. Is it bad practice for me to make them multiple lines for the sake of PEP8?

So should something like this:

patient = ([d['patient'] for d in doctor for s in sections if d == s['doctor']])


Be changed to something like this:

patient = []
for d in doctor:
  for s in sections:
   if d == s['doctor']:
    patient.append(d['patient'])


I find the first code block easier to read but it doesn't follow the PEP8 style guide so I was wondering if you had any tips.
How about breaking the lines like this:

patient = [doctor['patient']
           for doctor in doctors
           for section in sections if doctor == section['doctor']]


I find this more readable and it's PEP8 compliant.
I also removed the unnecessary (...) from around the expression,
and renamed doctor to the more intuitive doctors,
and used more meaningful loop variable names.

But the truth is I find it difficult to follow PEP8 always,
even though I really like clean code.
So I usually cheat,
and write a wrapper shell script to check my project and hide some PEP8 violations that I don't really want to follow.
Something like this:

#!/bin/bash

cd $(dirname "$0")

# E121 continuation line indentation is not a multiple of four
# E123 closing bracket does not match indentation of opening bracket's line
# E126 continuation line over-indented for hanging indent
# E128 continuation line under-indented for visual indent
# E501 line too long &gt; 79 characters
pep8 . | grep -v \
    -e E121 \
    -e E123 \
    -e E126 \
    -e E128 \
    -e E501