Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Write Better Python Cleaner Code PEP 8

Managing whitespace, how do the pros do it?

I noticed when I ran Flake8 on my code, Flake8 flagged several cases where I had extra whitespace in places where it did not belong, but Kenneth's badpep8.py file contained none of these whitespace mistakes. Is there something he and other experienced Pythonistas are doing to consistently avoid this issue? That is, how is Kenneth systematically avoiding accidentally leaving extra whitespace in places it doesn't belong without having to think about it? Clearly I have some bad habits right now when it comes to typing and navigating the page with the cursor because I had about 8 of these errors.

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

IDE editors usually include a syntax checker that constantly checks the syntax as you type. Vim, Emacs, PyCharm, Eclipse all have Python modes.

I like to run Emacs with a mode that automatically cleans up (β€œlints”) the code upon saving.

Thank you Chris Freeman . I found this distressing because these errors are invisible to the eye so it's good to know I don't have to look for them manually.