[Spambayes] Re: Corpus.Message.__getattr__ can't be correct can it?

Skip Montanaro skip at pobox.com
Sat Jan 18 11:56:49 EST 2003

    >> >> The __getattr__ method is really only meant to initialize payload
    >> >> and hdrtxt.
    Michael> In which case why not use a property?
    >> Why?  __getattr__ works fine, once it's properly written.

    Michael> I was thinking of its performance-mangling properties.  Dunno
    Michael> if that's an issue here, it was only an off-the-cuff remark.

I was thinking that the simplest solution which gives correct behavior would
be best.  Using properties would have required me to convert Corpus.Message
to a new-style class, and while that probably wouldn't have broken anything,
it wasn't a direct response to the bug.

Sure, __getattr__ can hurt performance, but in this case I think it's
reasonable.  It computes the necessary attribute values and updates them so
further accesses won't call __getattr__.


More information about the Spambayes mailing list