朋友不会让朋友用 Python 编写生产软件

  • Python was fun in the past with quick script writing and pleasant syntax.
  • Now it causes rage and sadness with non-trivial code due to type and exception issues.
  • Python uses duck typing, making it hard to determine variable types without running code.
  • Variables can have multiple types based on program flow, leading to runtime errors.
  • MyPy is a step in the right direction but has limitations and a bad syntax.
  • In a ~3500 LoC Python library/program, there are 25 # type: ignore annotations.
  • Python's exception management is poor with no way to declare raised exceptions.
  • Tools to validate caught exceptions are lacking.
  • Examples like re.compile, tarfile.open, and PIL show various possible exceptions.
  • Wrapping stdlib calls in try: … except Exception: is bad.
  • Dealing with untrusted file formats requires meaningful exceptions.
  • Python is old but still has issues like raising strange exceptions.
  • Don't let friends write production code in Python with weird file formats as things will explode.
阅读 7
0 条评论