Newbie (read: pot. stupid) question on objects/namespaces

Fred Pacquier fredp at multimania.com.nospam
Tue Aug 31 08:58:36 EDT 1999


Hi,

I tried looking this up in the FAQ/tutorial and failed, but maybe it's a 
terminology problem.

I'd like to know if it is possible, given the name of a "data attribute", 
to find out the name of its "owner", ie the instance (namespace) where it 
has been _created_ (the instance, not the class). This is probably unclear, 
so to illustrate :

def func(a_thing,...)
    	...

class foo:
    	self.thing = ...

class bar:
    	self.a_foo = foo()
    	func(self.a_foo.thing,...)

Here, 'func' (might be anywhere, top-level, another class, in the same 
module if it helps...) receives the data attribute 'thing' of instance 'a-
foo' of class 'foo'. This instance was created (by ? inside ?) class bar, 
or (probably) an instance 'a_bar' of class 'bar'.

The question is: given the simple call above with only the name as a 
parameter, is there a (legal) way for function 'func' to determine that 
'a_thing' actually (lives in ? belongs to ?) 'bar' (or 'a_bar') ?

Sorry if the question is really sick :-)

-- 
YAFAP : http://www.multimania.com/fredp/




More information about the Python-list mailing list