On Mon, Jun 15, 2009 at 5:43 AM, Virgil Stokes<v...@it.uu.se> wrote: > Does anyone have a good example (or examples) of when "property(...)" can be > useful?
Erm, when you want to create a property (i.e. computed attribute). from __future__ import division class TimeDelta(object): def __init__(self, secs): self. seconds =secs @property def minutes(self): return self.seconds/60 @property def hours(self): return self.minutes/60 @property def days(self): return self.hours/24 td = TimeDelta(55555555555) print td.days, "days", "=", td.hours, "hours", "=", td.minutes, "minutes" Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list