Python code cleanup for beginners. 7 steps to readable and maintainable code.
If you apply for a job, your take-home test task should be your best short.
Usually, it's easy to see when it's a beginner's code. Recruiters look at the project, and something immediately catches their eyes and bias their judgment: inconsistent formatting, clutter in the repository, leftovers of debugging prints, etc.
In his talk, Roman outlines common red flags that he saw reviewing test tasks and exploring public code on GitHub. Along with them, he provides some methods to make a good impression with your code, increase the chances to win that job offer, and become a better developer.
Introduction. For an experienced developer, it's easy to tell apart the beginner's code and the code of a seasoned developer. There are several best practices that experienced developers and teams try to follow, but it's an "unknown unknown" for newcomers.
Step 1. Declutter. Files that don't belong to the repository and the importance of .gitignore. Inside the code: unused imports, variables, commented out code, debugging prints.
- Step 2. No passwords in code. Follow 12-factor principles. Use tools like python-dotenv, django-environ, or dynaconf.
- Step 3. Make a readme. What should be in a good readme.
- Step 4. Add requirements. What is requirements.txt, and why it's important.
- Step 5. Paint it black. Why consistent formatting is important and how to get there with zero efforts with black.
- Step 6. Follow pep-8 conventions.
- Step 7. Use a linter. The difference between flake8 and pylint.
- Challenge. Apply all the improvements to your code and shout to the world
Only basic experience with python
Roman is a passionate software developer with 16 years of hands-on and team management experience. A big fan of Python, web, automation, and remote work. He helped organize pycon events in Russia and Belarus and was the leader of the Python community in Porto, Portugal. As a speaker, he participated in several conferences and local meetups, giving talks in Russian and English.
After eight years of working at doist.com as an individual contributor and the head of the Backend team, Roman continues his career as an independent consultant specializing in building high-quality software products with Python.