On Mon, 22 Oct 2007 17:31:51 -0600, Steven Bethard wrote: > Bruno Desthuilliers wrote: >> Computed attributes are IMHO not only a life-saver when it comes to >> refactoring. There are cases where you *really* have - by 'design' I'd >> say - the semantic of a property, but know from the start you'll need >> computation (for whatever reason). Then what would be the rationale for >> using explicit getters/setters ? > > I'd be interested to hear what these use cases are.
Stupid little example: A circle object with `radius` and `diameter` attributes. It doesn't make sense to store both a as normal attributes because they will eventually get out of sync. One can be implemented as a property. Another one is delegation of attribute access. I'm thinking of a wrapper class around an object with an attribute, say `is_active`, and a wrapper that has a property with the same name that returns the value of the wrapped objects attribute. Or lazy computation of an attribute. Breaks expectations for the first access -- long calculation for simple attribute access -- but meets it for every subsequent access. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list