Miscellaneous design and Python use questions

Neel Krishnaswami neelk at brick.cswv.com
Sat Feb 19 00:51:07 CET 2000

Travis B. Hartwell <travis at travis.aggievilla.org> wrote:
> 1)  When I do a typical OO-design with C++, I pay a lot of attention
> to information hiding.  I.E., I keep all of the data members private
> and rely on get/set functions to use them.  I feel that this is a good
> practice.  But, with Python, we don't have the access issue.  I still
> believe that information hiding is a good idea.  From the experienced
> Python developers, is it practice to use such functions within your
> classes?  Or do you just access things directly?  What are your
> thoughts on style regarding this?

Write it 3 times, and the right choice will be obvious the third time

The first version, you'll write garbage but learn the contours of the
problem domain; the second time you'll get a workable but ugly
solution; and the third time through you will build something that
*other people* will be happy reading and extending.

Remember, if your interface is good then people won't try to break
it. Consider: How often do C programmers break the FILE abstraction to
look at the implementation details? Not very often at all -- and C
programmers are notorious for breaking abstraction to do low-level
grovelling for even marginal speedups.


More information about the Python-list mailing list