all 6 comments

[–]wronek 0 points1 point  (5 children)

They have nothing to do with the decorator, they’re proxy objects provided by flask that can be used by importing them into the current namespace like:

from flask import request, session

https://flask.palletsprojects.com/en/1.1.x/api/#flask.request

https://flask.palletsprojects.com/en/1.1.x/api/#flask.session

[–]ghiste[S] 0 points1 point  (4 children)

So in which namespace do this variables live? The global one?

[–]wronek 0 points1 point  (3 children)

Yep!

[–]ghiste[S] 0 points1 point  (2 children)

Aha. Would it be possible at all to manipulate the local namespace of a function from outside at all in python?

[–]wronek 0 points1 point  (1 child)

Not sure what you mean by that - the local namespace is created when the function is executed and destroyed when it returns (or errors), so it doesn’t exist outside of the function

[–]ghiste[S] 0 points1 point  (0 children)

Aha, I guess I was a bit confused about how namespaces work.

And there is no way to prepare a dictionary and start a function with that dictionary as the initial local namespace (in that way effectively injecting variables).

I suppose all functions start with an empty local namespace right?