what mechanism is taking place that defines what symbols go where in this? i ask because i am seeing that non-function symbol names that were not expressed in the import statement are not visible to the caller (which imported the function it calls), but are visible to that function.
1. is it a different global space?
2. is it a mechanism that makes two (or more) namespaces appear as one (like an overlay filesystem does).
3. is python putting the symbols in when the function is being called and taken backout when it returns?
in the unnamed language i was designing, that design does a similar thing, but achieves it by an overlay where all code always sees everything that is where it comes by a means of an overlay with locals on top. if the code is referenced via an instance (a class object), then a 4th layer for the instance is also there (allowing objects to keep data local, or save it with the object instance, or share it among all instances of the same class (more layers here for inherited instances), or globally (the caller can get to here).
i'm wanting to understand how Python does it, in terms of what the language is supposed to give us, as opposed to any artifacts of some implementation. i am planning to make a little storage module that can do this for caller functions. i have dabbled in this and it seems to work. more complex cases like separate imports have yet to be tested. but i hate determining this by test code because it will include the artifacts of the CPython implementation i have.
what is this nonlocals={} ? yet another space? where do the real locals fit in?
1. is it a different global space?
2. is it a mechanism that makes two (or more) namespaces appear as one (like an overlay filesystem does).
3. is python putting the symbols in when the function is being called and taken backout when it returns?
in the unnamed language i was designing, that design does a similar thing, but achieves it by an overlay where all code always sees everything that is where it comes by a means of an overlay with locals on top. if the code is referenced via an instance (a class object), then a 4th layer for the instance is also there (allowing objects to keep data local, or save it with the object instance, or share it among all instances of the same class (more layers here for inherited instances), or globally (the caller can get to here).
i'm wanting to understand how Python does it, in terms of what the language is supposed to give us, as opposed to any artifacts of some implementation. i am planning to make a little storage module that can do this for caller functions. i have dabbled in this and it seems to work. more complex cases like separate imports have yet to be tested. but i hate determining this by test code because it will include the artifacts of the CPython implementation i have.
what is this nonlocals={} ? yet another space? where do the real locals fit in?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.