getattr



This question is regarding the __getattr__ function defined for every
object.
Consider the following example

Assume that foo is an instance of class Foo, and the following are
references to foo's field "bar" which is an instance of class Bar

a) foo.bar
b) foo.bar.spam - spam is a member of "bar"

I want the above references to be handled by __getattr__. Hence I do
not have an entry for the 'bar' in foo.__dict__

Is there any way by which the __getattr__(self,attr) method can
determine that in
case a) attr == 'bar' is the final component in the reference unlike in
case b) where attr=='bar' is NOT the ultimate(final) component of
reference and is an intermediate component in the reference.

tia

.



Relevant Pages

  • Re: get object name
    ... the name of the class is Bar. ... a reference to an instance of an object, ... A class is a blue-print. ... Just about any of the OO literature by the recognized authorities out ...
    (comp.lang.php)
  • Re: Problems with view editor
    ... In the ViewComposer deleting a view resource from the composition arena using the "Edit\Delete" command from the menu bar removes the resource from its class. ... when dropping it on another view as a reference view. ...
    (comp.lang.smalltalk.dolphin)
  • Re: Shorthand for($scalar) loops and resetting pos($scalar)
    ... >> the loop will modify $scalar outside it. ... 'bar' variables would be aliases for ALL 'foo' variables. ... that would make $_ a REFERENCE to $scalar. ...
    (comp.lang.perl.misc)
  • Re: How to get a listing of module functions
    ... After creating a reference to an object, ... my $foo = new Foo; ... my $bar = new Bar; ...
    (comp.lang.perl.misc)
  • Re: get object name
    ... Bar...and unless Bar has a method called 'getName', ... A variable stores a reference to an instance of an object, not the class which defines it. ... Whether or not you consider an object to be an instance of a class or just the computer's product from a blue-print is COMPLETELY IMMATERIAL. ...
    (comp.lang.php)