top | item 28742863

(no title)

arathore | 4 years ago

> When printing tracebacks, the interpreter will now point to the exact expression that caused the error instead of just the line. For example:

  Traceback (most recent call last):
    File "distance.py", line 11, in <module>
      print(manhattan_distance(p1, p2))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "distance.py", line 6, in manhattan_distance
      return abs(point_1.x - point_2.x) + abs(point_1.y - point_2.y)
                             ^^^^^^^^^
  AttributeError: 'NoneType' object has no attribute 'x'
This is such a great quality of life improvement.

discuss

order

RheingoldRiver|4 years ago

This is an INCREDIBLE improvement. I'm so excited for it for myself, and I think it will also do wonders for getting new programmers comfortable with the language. Seeing exactly where in the line your error is, is amazing! IMO this 100% cements Python as the single most newbie-friendly language, if there was any question before now (or at least, before the release of 3.11).

pletnes|4 years ago

I already move code into separate lines since this is currently missing. This is great indeed. (Although that might still make sense for debugging)

BiteCode_dev|4 years ago

Well if you like this, you are going to love 3.10 due for tomortow, because it's packed with a lot of error message improvements.

Everybody talks about the pattern matching, but I'm excited about this. I'm going to upgrade ASAP just so for it.

Alex3917|4 years ago

Oh wow, I completely missed this in the release notes, probably due to not carefully reading them since earlier versions. This is amazing!

junon|4 years ago

Really wish they'd just go and add a way to replace better-exceptions[0]. I don't use it anymore and thus don't really like to maintain it these days, and would love to see it in mainline.

[0] https://GitHub.com/qix-/better-exceptions