Follow

@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.

@cnx ah, i always forget about with. i never really used it, it somehow never felt "right". i think i'm just not a python guy :D @thor

@bonifartius, at this point context managers (the with thing) 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-harmful

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.

Cc: @thor

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.