+ 9
[Python] A function attribute is not a local?
Where do I find f.a? https://code.sololearn.com/c39Elhwdu0hE/?ref=app
4 Respostas
+ 7
function attributes are not local variables, but are added to the func_dict for the function in a key : value relationship. They can be accessed via the __dict__ of the function.
print(fun.__dict__)
https://www.python.org/dev/peps/pep-0232/
+ 4
https://docs.python.org/3.9/reference/datamodel.html#objects-values-and-types
Scroll down to callable types.
Also, lookup __dict__
The PEP is probably the most informative from what I've seen.
+ 2
ChaoticDawg thanks!
you have a docu for it?
+ 2
Mirielle yes.
f.a is different to b. And thinking about the difference and locals() akes everything a bit clearer.