[Tutor] Builtin "property" decorator hiding exceptions
Jacob Abraham
jakieabraham at yahoo.com
Thu Apr 19 08:07:32 CEST 2007
Hi,
The sample script below throws the exception "AttributeError: input" rather than the expected exception "AttributeError: non_existent_attribute".
Please help me write a decorator or descriptor of my own that fixes the issue.
class Sample(object):
def __init__(self):
self.arguments = {}
def __getattr__(self, name):
ret_val = self.arguments.get(name, None)
if ret_val != None: return ret_val
raise AttributeError, name
@property
def input(self):
self.non_existent_attribute
sample = Sample()
sample.input
Regards,
Jacob Abraham
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Tutor
mailing list