Does Python really follow its philosophy of "Readability counts"?

Luis Zarrabeitia kyrie at uh.cu
Mon Jan 19 23:57:46 EST 2009


Quoting "Russ P." <Russ.Paielli at gmail.com>:

> In the circle example, properties are nice for guaranteeing
> consistency between the radius and the area, but they are not of much
> use if you decide later that the client should not be allowed to
> change either one. Well... I suppose you could define the setter to do
> nothing ... but you had better figure a way to notify the client about
> it.

Well, you could make it raise an exception. There was one C#1.0 class that did
this, Liskov substitution principle be damned (it was for a subtype). Very
frustrating. 

Once you decide for a public interface, you shouldn't change it... But, if you
absolutely have to do it, complain loudly and as soon as possible. In python,
I'd say that [a subclass of?] AttributeError would be the best solution for this
ill-advised situation.

-- 
Luis Zarrabeitia
Facultad de Matemática y Computación, UH
http://profesores.matcom.uh.cu/~kyrie



More information about the Python-list mailing list