[PEAK] Persistence styles, MDA, AOP, PyProtocols, and PEAK
Robert Brewer
fumanchu at amor.org
Thu Jul 8 01:40:25 EDT 2004
Stephen Waterbury wrote:
> Robert Brewer wrote:
> > (replying off-list)
> > No, I think I got it the first time. ;) You're using
> composition ("has
> > a") where I use subclassing ("is a").
>
> No, actually you *still* didn't quite get it. ;)
I should have guessed that. ;)
> Cool -- just a slightly different approach from mine.
> Here's how it would look in PanGalactic.
Gargleblasters anyone? ;)
> def getBalanceDue(self):
> return self.amount - self.paid
> def setBalanceDue(self, value):
> raise TypeError, 'Nuh uh!'
> def delBalanceDue(self):
> raise TypeError, 'Hah, nice try!'
> balance_due = property(getBalanceDue, setBalanceDue,
> delBalanceDue, 'balance due')
Looks good! You might want to check into coding your own descriptors
instead of using properties--it really cuts down on the boilerplate
(obviously the above is just an example, but still...).
Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org
More information about the PEAK
mailing list