Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add line breaks to increase code readability #1

Open
sen1 opened this issue Apr 30, 2018 · 0 comments
Open

Add line breaks to increase code readability #1

sen1 opened this issue Apr 30, 2018 · 0 comments

Comments

@sen1
Copy link

sen1 commented Apr 30, 2018

Capstone/musclehub.py

Lines 125 to 135 in 808f4ed

df = sql_query(''' SELECT
visits.first_name, visits.last_name, visits.gender, visits.email, visits.visit_date,
fitness_tests.fitness_test_date, applications.application_date, purchases.purchase_date
FROM visits
LEFT JOIN fitness_tests
ON visits.first_name = fitness_tests.first_name AND visits.last_name = fitness_tests.last_name AND visits.email = fitness_tests.email
LEFT JOIN applications
ON visits.first_name = applications.first_name AND visits.last_name = applications.last_name AND visits.email = applications.email
LEFT JOIN purchases
ON visits.first_name = purchases.first_name AND visits.last_name = purchases.last_name AND visits.email = purchases.email
WHERE visits.visit_date >= '7-1-17'

Great job here. However, I would add line breaks to increase code readability. We did not follow code styling very closely in this course. However, it is very important. I would do:

df = sql_query('''
SELECT visits.first_name,
       visits.last_name,
       visits.visit_date,
       fitness_tests.fitness_test_date,
       applications.application_date,
       purchases.purchase_date
FROM visits
LEFT JOIN fitness_tests
    ON fitness_tests.first_name = visits.first_name
    AND fitness_tests.last_name = visits.last_name
    AND fitness_tests.email = visits.email
LEFT JOIN applications
    ON applications.first_name = visits.first_name
    AND applications.last_name = visits.last_name
    AND applications.email = visits.email
LEFT JOIN purchases
    ON purchases.first_name = visits.first_name
    AND purchases.last_name = visits.last_name
    AND purchases.email = visits.email
WHERE visits.visit_date >= '7-1-17'
''')

The PEP8 guide for the maximum length of a code line:
https://www.python.org/dev/peps/pep-0008/#maximum-line-length

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant