An interesting python problem

Steve Holden steve at holdenweb.com
Wed Sep 14 07:32:10 EDT 2005


Adriaan Renting wrote:
> In my mind all Python variables are some kind of "named pointers", I find that thinking this way helps me a lot in understanding what I'm doing. I know that this is not completely technically correct as in the first two examples there is actually a new a.i/a.arr created that shadows A.i, but thinking like this helps me. Are there fundamental flaws to think this way?
> 
[...]
This is a very good way to think about it. Each name lives in a specific 
namespace, and the interpreter has a defined order of namespaces when it 
tries to resolve a name. But the data objects that the names point to 
live in what I like to think of as "object space", and in the CPython 
implementation are garbage collected when the last pointer to them is 
deleted (or, equivalently, goes out of scope).

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC             http://www.holdenweb.com/




More information about the Python-list mailing list