@thor early returns are good style imho, but maybe that's because i use go so much and there it's idiomatic. i never really liked the control flow by exception which is rather common in python.
@bonifartius and @thor, it’s very common that a try-except-finally can be replaced by a with, and when it isn’t, most likely the else is needed and kinda clean. I’d prefer an expression try like in Raku or Zig any day but at least Python scoping allow you to except only a variable definition.
IMHO languages should either have no exceptions at all or provide a RAII-like syntactic sugar like in Python. Anything in between is just a waste of human and computing resources.
CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.
@bonifartius, at this point context managers (the
withthing) are the only thing keeping me doing Python. It’s capable of expressing pretty sick shits: https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmfulIMHO languages should either have no exceptions at all or provide a RAII-like syntactic sugar like in Python. Anything in between is just a waste of human and computing resources.
Cc: @thor