News for hackers. Stuff that matters.
Re:Python 3.11 by arathore on Sunday October 03, 2021 @11:49PM (#28742863)
> 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.
Re:Python 3.11 by RheingoldRiver on Monday October 04, 2021 @12:42AM (#28743169)
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).
Re:Python 3.11 by aroberge on Monday October 04, 2021 @06:17AM (#28744984)
You can already get this information for Python 3.6+ with https://friendly-traceback.github.io/docs/index.html
Re:Python 3.11 by pletnes on Monday October 04, 2021 @02:40AM (#28743766)
I already move code into separate lines since this is currently missing. This is great indeed. (Although that might still make sense for debugging)
Re:Python 3.11 by throwaway81523 on Monday October 04, 2021 @03:49AM (#28744186)
It would sure be great if they made it easier to break to the debugger in case of an unhandled exception, like (setq debug-on-error t) in Emacs Lisp.
Re:Python 3.11 by pletnes on Monday October 04, 2021 @06:31AM (#28745052)
This can be done in some IDEs. Although it can get confusimg if you’re working in an app framework that does some sort of catch-all exception handling.
Re:Python 3.11 by throwaway81523 on Tuesday October 05, 2021 @03:54PM (#28764744)
Yeah it seems to me that regular Python should be able to do it though.
Re:Python 3.11 by BiteCode_dev on Monday October 04, 2021 @03:55AM (#28744219)
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.

Re:Python 3.11 by Alex3917 on Monday October 04, 2021 @10:13AM (#28746962)
Oh wow, I completely missed this in the release notes, probably due to not carefully reading them since earlier versions. This is amazing!
Re:Python 3.11 by junon on Monday October 04, 2021 @03:34AM (#28744110)
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

Re:Python 3.11 by Moosdijk on Monday October 04, 2021 @03:13AM (#28743983)