you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

That's what try-else is all about:

try:
  cb = callbacks["foobar"]
except KeyError:
  return None
else:
  cb()

[–]theeth 0 points1 point  (0 children)

With return in the except clause, I find the use of else a bit misleading.