1👍
If I understand your question right, you can’t do what you’re trying to do, and what’s more, you really shouldn’t. Whatever base_obj.obj1
is, base_obj.obj1.type
will get the type
attribute of that, because base_obj.obj1.type
means (base_obj.ob1).type
— that is, it evaluates the obj1
attribute first. There is no way to make base_obj.obj1
return one thing, but have the base_obj.obj1
part of base_obj.obj1.type
be something different. At the time the lookup of obj1
happens, you do not know whether another attribute lookup is going to take place later.
There are good reasons for this. It would be very confusing if these gave different results:
# 1
x = base_obj.obj1.type
# 2
tmp = base_obj.obj1
x = tmp.type
If you want to get the value
attribute, get the value
attribute. If you want to be able to use obj1
in various situations as if it were its value attribute, you may be able to achieve what you want by overloading various operations on obj1
(so that, e.g., base_obj.obj1 + 2
works).