I'm having trouble understanding what is happening here with this code based on the explanation given below:
def route(self, path):
def wrapper(handler):
self.routes[path] = handler
return handler # returns
return wrapper
Here is the explanation that was given:
"in the route method, you took a path as an argument [note: the path here is a dictionary as follows: {"/home": <function home at 0x1100a70c8>} ] and in the wrapper method you added this path in the self.routes dictionary as a key and the handler as a value"
Something does not make sense here. Here are the questions I have?
is the wrapper(handler) inheriting its argument from route(..., path)?
If the handler argument is already a dictionary, i.e
{"/home": <function home at 0x1100a70c8>}
, being passed from path, how then does self.routes[path] = handler set path as a key and handler as a value? Doesn't make sense to me.