Skip to main content

Recommended Books for Learning Python

  • People who want to study machine learning but have never touched Python

  • People who need Python for Django, Flask, etc.

    This article describes how to learn Python as a programming language for those audiences.

Programming in Python

What Makes Code Readable

  • Strive to write clear, readable, and concise code that even your future self a year from now can understand. Reading other people's code and having others review yours is an invaluable experience.
  • Keep functions and files at a reasonable length. If there are too many comments, consider whether the function and variable names could be more descriptive. When refactoring, tests are essential.
  • Recommended book: "The Art of Readable Code"

What It Means to Read Source Code

  • Reading source code means understanding a program's behavior and design intent. When starting out, it is important to actually run the code and observe its behavior through techniques like print debugging.
  • Techniques for Reading Source Code (Cheat Sheet)

Object-Oriented Programming

  • Object-oriented programming is (to put it in one phrase) a way of organizing programs. It groups functions and data by purpose, making designs easier to understand and improve. It is good to be mindful of this when designing classes in Python as well.
  • [Illustrated] What is Object-Oriented Programming?: https://26gram.com/what-is-object-oriented

Design Patterns

  • Design patterns are (to put it in one phrase) methods for separating programs by role. Good separations from the past have been given names for easy reuse. Once you learn patterns, you may feel the urge to use them everywhere, but choosing not to use one is also a valid pattern. It is useful to at least have an overview of design patterns even when working with Python.
  • Learning Design Patterns Through Examples: https://www.ogis-ri.co.jp/otc/hiroba/technical/DesignPatternsWithExample/chapter01.html

Testing Is Important

  • In production code, tests sometimes make up more than half of the codebase -- that is how important testing is. From verifying correct behavior to ensuring no regressions (bug introductions) during refactoring, good code always comes with tests. There is even something called TDD (Test-Driven Development).

Handling Source Code

Coding Guidelines

  • Production code should follow common readability rules rather than personal style.
  • As a rule, use lint tools like flake8 during development. Some projects also recommend black, so be sure to check.
  • Coding conventions will be explained in detail in a separate article.

Further Ways to Improve Your Programming

Toward Advanced Programming