FEEDBACK WANTED: Type/class unification

Markus Schaber markus at schabi.de
Thu Aug 2 17:43:02 CEST 2001


Hi,

Guido van Rossum <guido at python.org> schrub:

> [...] We could easily have a shortcut that creates a pair of accessor
> functions to map a public attribute name to a private attribute, but
> what good would it do us?  You only need to use accessor functions
> when you want additional functionality.  

Yes, and in some cases, I only want to add functionality to one of the 
accessor functions.

Imagine that you want to increase a read counter when getting an 
attribute, i. E. when you try to implement some LRU caching

Or one would want to restrict access to an object, or do some 
calculations every get.

Another case would be performing checks or calculations needed when 
setting an attribute, but reading is just "straight forward".

In those cases, you could use the shortcut for the other accessor 
function to create it implicitly.

Another idea may be to provide both standard accessor functions so that 
subclasses may easily override one or the other.

markus
-- 
Defend democrathy and freedom!



More information about the Python-list mailing list