Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 67,995 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.