Q:

How to prevent multiple catching of exception

Is there a way to prevent multiple catching of exceptions while they ride up the stack to the top level of the program? 
Here is a very simplified code example that illustrate the phenomenon:
def try_except_block(smthg):
   try:
     smthg.run()
   except Exception as e:
     print("WRONG")
     raise e

def re_call():
   f2 = Foo(True) # will throw an exception
   try_except_block(f2)

class Foo:
  def __init__(self, t):
    self.throw = t
  def run(self):
    if self.throw:
      raise KeyError
    else:
      re_call()

if __name__ == '__main__':
  f = Foo(False) # won't throw an exception
  try_except_block(f)

output:
WRONG
WRONG
Traceback (most recent call last):
  File "exception_loosing_args.py", line 26, in <module>
    try_except_block(f)
  File "exception_loosing_args.py", line 9, in try_except_block
    raise e
  File "exception_loosing_args.py", line 6, in try_except_block
    smthg.run()
  File "exception_loosing_args.py", line 22, in run
    re_call()
  File "exception_loosing_args.py", line 13, in re_call
    try_except_block(f2)
  File "exception_loosing_args.py", line 9, in try_except_block
    raise e
  File "exception_loosing_args.py", line 6, in try_except_block
    smthg.run()
  File "exception_loosing_args.py", line 20, in run
    raise KeyError
KeyError

I would like to print only once "WRONG". 
In my software, the try_except_block function is wrapped into an object, I have had the idea to set an attribute of this object which could flag the exception statement as "already visited" or not.  I don't like this idea because of the possible side effects which could be lead by this pratice.  Is there an other one? 
exemple of what I had in mind (the class attribute is emulated by a global variable flag):
flag = False

def try_except_block(smthg):
   global flag
   try:
     smthg.run()
   except Exception as e:
     if not flag:
       print("WRONG")
       flag = True
     raise e

def re_call():
   f2 = Foo(True) # will throw an exception
   try_except_block(f2)

class Foo:
  def __init__(self, t):
    self.throw = t
  def run(self):
    if self.throw:
      raise KeyError
    else:
      re_call()

if __name__ == '__main__':
  f = Foo(False) # won't throw an exception
  try_except_block(f)

output:
WRONG
Traceback (most recent call last):
  File "exception_loosing_args.py", line 28, in <module>
    try_except_block(f)
  File "exception_loosing_args.py", line 11, in try_except_block
    raise e
  File "exception_loosing_args.py", line 6, in try_except_block
    smthg.run()
  File "exception_loosing_args.py", line 24, in run
    re_call()
  File "exception_loosing_args.py", line 15, in re_call
    try_except_block(f2)
  File "exception_loosing_args.py", line 11, in try_except_block
    raise e
  File "exception_loosing_args.py", line 6, in try_except_block
    smthg.run()
  File "exception_loosing_args.py", line 22, in run
    raise KeyError
KeyError

A:

I don't fully understand why your code does what it does, but a thing you could do that might suit is to mark exception objects as already-seen, rather than setting a global flag.   Like so:
def try_except_block(smthg):
    try:
        smthg.run()
    except Exception as e:
        if not hasattr(e, "teb_already_seen"):
            setattr(e, "teb_already_seen", True)
            print("WRONG")
        raise e

That way, the extra processing done by try_except_block will only happen once per exception object, which is probably what you want.