Live, Learn, and Lung

Tag: Python

  • Ensuring Code Quality with pre-commit Hooks

    A hallmark of clean code is consistent formatting, which becomes important when collaborating in a team. While manually using formatters or linters to check code is possible, it’s easy to forget. A more effective approach is to use tools like pre-commit hooks for automated code inspection before committing. The code in this post is available…

  • Using Docker to Run Your Python Tests

    Have you ever encountered the frustrating ‘It works on my machine’ problem? This is a common headache in software development. Docker containers provide a solution by packaging your code in a consistent environment. Because of this, Docker has become popular in many areas, especially for automating CI/CD pipelines. In this post, I’ll show you how…

  • Managing Project Dependencies with Poetry

    When building Python projects, we inevitably need to work with third-party packages. Most developers start with the familiar requirements.txt approach, but this method has its pitfalls. It’s all too common to install a new package and forget to update the requirements file. Even worse, when you look at your requirements.txt, it’s hard to distinguish between…

  • Getting Started with pytest: A Beginner’s Guide to Python Testing

    Have you ever found yourself inheriting legacy code and questioned its functionality after refactoring? Or, have you made changes to your code and wondered if it still works correctly? If you’ve experienced either of these scenarios, it’s time to consider implementing tests for your code. In this article, we will cover the basics of pytest…

  • Principle of Clean Python Code – Naming, Comments, Functions

    Writing clean code is a fundamental goal to enhance code readability, comprehension, and maintainability. It is considered a best practice to adhere to clean code principles when developing in Python. In this article, we will explore key principles of clean Python code, focusing on naming conventions, commenting practices, and function design. Naming PEP 8 has…