python development practices?

James_Althoff at James_Althoff at
Wed Oct 31 21:20:36 CET 2001

Cliff Wells wrote:
>I tend to use this method as well.  My feeling is that keeping data
>attributes private (by convention) helps keep classes as "black boxes".
>allows the internal implementation of the class to change at will as long
>the get/set methods provide the same interface.  This allows things such
>changing a list to a dictionary without fear that this will break some
>outside code.

Absolutely!  The ability to change a class implementation whilst preserving
backwards compatibility via the safety net of method access has saved the
derriere on numerous occasions.  (The very notion of hard-coded access to
instance variables strewn about in random pieces of code in a large system
just flat-out gives me the willies.  For me, the really important thing is
actually *to buy into* the idea of encapsulation).


More information about the Python-list mailing list