Polymorphism the Python way

sismex01 at hebmex.com sismex01 at hebmex.com
Tue Sep 2 15:41:14 CEST 2003


[Graham Fawcett]
>Then you can access the attribute as `someobj.thing`.
>
>Given that you hate getters, and that you didn't title your 
>message, "Encapsulation the Python Way", accessing instance 
>attributes directly is fair game.  ;-)
  

[Daniel Klein]
> Yes, I could do this, but a method provides better control over the
> state.

In that case you should use a Property, which is accessed
as an ordinary attribute, but it has (up to) three hidden
methods bound to it, a getter, a setter and a deletter;
it seems to be just what the doc ordered, for you that is.

-gustavo


Advertencia:La informacion contenida en este mensaje es confidencial y
restringida, por lo tanto esta destinada unicamente para el uso de la
persona arriba indicada, se le notifica que esta prohibida la difusion de
este mensaje. Si ha recibido este mensaje por error, o si hay problemas en
la transmision, favor de comunicarse con el remitente. Gracias.





More information about the Python-list mailing list