flask decorator causes views to be named the same thing 1

flask decorator causes views to be named the same thing

def exception_handler(func):
  def wrapper(*args, **kwargs):
  # Renaming the wrapper name to the function name:
  wrapper.__name__ = func.__name__
  return wrapper

Here is what the above code is Doing:
1. The function wrapper() is defined inside the function exception_handler().
2. The function wrapper() is returned by the function exception_handler().
3. The function wrapper() is assigned to the variable func.
4. The function wrapper() is called.
5. The function wrapper() calls the function func().
6. The function func() returns a value.
7. The function wrapper() returns the value.

Similar Posts