J
Jure Erznožnik
I'm trying to create a class that would lie to the user that a member is insome cases a simple variable and in other cases a class. The nature of themember would depend on call syntax like so:
1. x = obj.member #x becomes the "simple" value contained in member
2. x = obj.member.another_member #x becomes the "simple" value contained in first member's another_member.
So the first method "detects" that we only need a simple value and returns that. The second method "sees" that we need "member" as a class and returnsthat. Note that "simple type" could mean anything, from int to bitmap image.
I have determined that this is possible if I sacrifice the final member reference to the __call__ override using function-call syntax: 1. x = obj.member(). The call syntax returns the simple value and the other returns the class. It is also possible if I override the __xxxitem__ methods to simulate a dictionary.
However, I would like to use the "true member" access syntax if possible.
So, is it possible?
1. x = obj.member #x becomes the "simple" value contained in member
2. x = obj.member.another_member #x becomes the "simple" value contained in first member's another_member.
So the first method "detects" that we only need a simple value and returns that. The second method "sees" that we need "member" as a class and returnsthat. Note that "simple type" could mean anything, from int to bitmap image.
I have determined that this is possible if I sacrifice the final member reference to the __call__ override using function-call syntax: 1. x = obj.member(). The call syntax returns the simple value and the other returns the class. It is also possible if I override the __xxxitem__ methods to simulate a dictionary.
However, I would like to use the "true member" access syntax if possible.
So, is it possible?