Sobes.tech
Junior — Middle

What common mistakes have you had to correct in your practice?

sobes.tech AI

Answer from AI

In Python development practice, the following common errors often occur:

  • Data type errors, such as attempting to perform operations between incompatible types (string and number).
  • Scope issues, especially in functions and closures.
  • Incorrect use of mutable and immutable objects, leading to unexpected side effects.
  • Errors when working with asynchronous code, such as forgotten await or incorrect use of the event loop.
  • Exception handling problems, where exceptions are either not handled or handled too broadly.
  • File and resource management errors, such as forgotten file closures or incorrect use of context managers.

Example of a typical type error:

value = "123"
number = value + 10  # TypeError: can only concatenate str (not "int") to str

To fix this, convert types to compatible ones:

number = int(value) + 10  # 133