The Python Oracle

Is it possible to modify a variable in python that is in an outer (enclosing), but not global, scope?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: A Thousand Exotic Places Looping v001

--

Chapters
00:00 Question
01:10 Accepted answer (Score 195)
02:09 Answer 2 (Score 27)
02:39 Answer 3 (Score 14)
03:11 Answer 4 (Score 2)
03:29 Thank you

--

Full question
https://stackoverflow.com/questions/8447...

Question links:
[How can I access variables from the caller, even if it isn't an enclosing scope (i.e., implement dynamic scoping)?]: https://stackoverflow.com/questions/1560.../

Accepted answer links:
[nonlocal]: https://docs.python.org/3/reference/simp...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #pythonnonlocal

#avk47