[Spambayes] Corpus.Message.__getattr__ can't be correct can it?
Skip Montanaro
skip at pobox.com
Fri Jan 17 14:10:34 EST 2003
Just> Neither makes sense (unless I'm missing some magic context):
Just> __getattr__ is only called if the attr isn't found the normal way,
Just> which means it's for sure not in self.__dict__.
Well, I think Richie meant it should be:
def __getattr__(self, attributeName):
'''On-demand loading of the message text.'''
if attributeName in ('hdrtxt', 'payload'):
self.load()
try:
return self.__dict__[attributeName]
except KeyError:
raise AttributeError, attributeName
That is, __getattr__ is called when hdrtxt or payload are accessed but not
yet initialized. All other accesses (or if self.load() fails somehow)
should raise AttributeError. See Corpus.py 1.3.
Skip
More information about the Spambayes
mailing list