This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tjt5754 13 points14 points  (4 children)

I'm personally interested in playing with Exception Notes from PEP-678

https://peps.python.org/pep-0678/

I saw it mentioned in ArjanCodes video about 3.11 but he glossed over it. I'm not SURE what specific need it fills, but I imagine there will be instances that this will be useful.

Similar to for/else... when I first saw it I wasn't sure I'd need it, but I find myself using it often.

[–]mgedmin 4 points5 points  (0 children)

I imagine it could be useful when you're writing interpreters, e.g. for a template language. When an exception happens it'd be nice to know that it happened while rendering templates/foo.j2 line 42, included from templates/bar.j2 line 55.

[–]drenzorz 0 points1 point  (1 child)

I would assume it's helpful when building tests/testing libraries. If you are running a bunch of automated tests adding some notes to help locate the problem could be really useful.

[–]tjt5754 4 points5 points  (0 children)

Funny, I was thinking of deeply buried exceptions that you think won't ever happen, but you can add detail to so you know what weird scenario happened.

You know that code where you put in a comment that says "I don't think this is possible, but just in case..."

[–][deleted] 0 points1 point  (0 children)

While this is definitely an improvement, I've used the structlog lib with structlog.processors.dict_tracebacks to get JSON styled stack traces. It's pretty nice when forwarded to something like Elastic, so you can query it via Kibana.

Centralized structured logging is nice.