I've now run into this difficulty a couple of times, but I'm still a bit puzzled about it. There are circumstances when I will pass a view as a parameter to a class constructor and things work fine. The callee gets the view and can access it without difficulty.
There are other cases where I do (almost) the same thing, the callee gets the view, but a later access to it fails. On entry to the callee, the view is okay. But at some point apparently some "part" of the view is garbage collected, dereferenced, goes out of scope, or whatever and *some* properties of the view become inaccessible (determined by the dreaded internal Python interpreter error exception), though some *other* properties of the view are still accessible. For example, 'len(view)' works, but 'view[0].propertyName' does not. My original thought was that in the callee (constructor for the class being instantiated) all I would need to do was to create a self.view to hold a reference to the incoming view parameter. Then any of that class's methods should have a reliable reference to the view. But this is not sufficient. I have discovered that if instead I do 'self.view = view.copy()', then things go well. What I'm puzzled about is *when* I need to do the copy() and when I do not. I think there are some arcane Python scoping issues here, but I wonder if there are any guidelines (beyond, "If it doesn't work the way you think it should, make a copy."). I'm also puzzled because I don't seem to have the problem with other (i.e., non-view) objects in general. I also wonder if this is in fact what should reasonably be expected, or if there is some possibility of a subtle bug (or at least incompatibility) between the underlying C++ implementation and Python's approach to memory management and scoping. Any thoughts? -------------------------------------- Gary H. Merrill Director and Principal Scientist, New Applications Data Exploration Sciences GlaxoSmithKline Inc. (919) 483-8456 _______________________________________________ metakit mailing list - [EMAIL PROTECTED] http://www.equi4.com/mailman/listinfo/metakit
