Message249559
This looks a bit inconsistent. See following version with "manual" getter definition:
class MyClass(object):
def __init__(self, *args, **kwargs):
# setting access to getter by attribute
# without use of property decorator
self.__dict__['myproperty'] = self._myproperty()
def __getattr__(self, name):
print('__getattr__ <<', name)
raise AttributeError(name)
return 'need know the question'
def _myproperty(self):
print(self.missing_attribute)
return 42
my_inst = MyClass()
print(my_inst.myproperty)
# Produces (expected) output
__getattr__ << missing_attribute
Traceback (most recent call last):
File "a.py", line 55, in <module>
my_inst = MyClass()
File "a.py", line 33, in __init__
self.__dict__['myproperty'] = self._myproperty()
File "a.py", line 48, in _myproperty
print(self.missing_attribute)
File "a.py", line 37, in __getattr__
raise AttributeError(name)
AttributeError: missing_attribute
I'd expect the original version using property decorator would behave the same way. Possible issue in property class implementation ? |
|
Date |
User |
Action |
Args |
2015-09-02 18:47:09 | dunric | set | recipients:
+ dunric, martin.panter, eryksun |
2015-09-02 18:47:09 | dunric | set | messageid: <1441219629.86.0.981038973422.issue24983@psf.upfronthosting.co.za> |
2015-09-02 18:47:09 | dunric | link | issue24983 messages |
2015-09-02 18:47:09 | dunric | create | |
|