One-Shot Property?

Kevin Smith Kevin.Smith at
Tue Jan 18 11:54:56 EST 2005

I have many cases in my code where I use a property for calculating a 
value on-demand.  Quite a few of these only need to be called once.  
After that the value is always the same.  In these properties, I set a 
variable in the instance as a cached value and return that value on 
subsequent calls.  It would be nice if there was a descriptor that would 
do this automatically.  Actually, what would be really nice is if I 
could replace the property altogether and put the calculated value in 
its place after the first call, but the property itself prevents me from 
doing that.  Is this possible?

Kevin Smith
Kevin.Smith at

More information about the Python-list mailing list