Dec-16-2020, 05:48 PM
(Dec-16-2020, 10:09 AM)Pedroski55 Wrote: Well, "where does bar get a value for x?"LEGB describes why bar() can see x (though it cannot change x), but it does not explain why in my example a sees x=10 and b sees x=20. In C it is easy to pass s function pointer around, but that pointer does not come with it's own little piece of frozen space time. This is a very cool, and slightly frightening, demonstration of a feature that may be uniquely Python.
Reuven Lerner talked about LEGB: Python looks in: Local, Enclosing, Global, then Builtin for x
Still not sure I understand this, but I am a slow learner!