The benefit of properties (was Re: PEP 8: on member variables vs. attributes)

Peter Hansen peter at
Fri Jan 17 20:20:49 CET 2003

Donn Cave wrote:
> In my world, everyone who deals with code is eventually liable to care
> how it works.  Especially with regard to state changes or side effects.
> Not so much because we're itching to exploit this knowledge for evil
> violations of one kind or another, more because it's eventually the only
> way to understand why it works the way it does.  (Note ``eventually'',
> I'm speaking of a last resort but a common one.)  We can't afford to
> make code opaque to anyone.

One of the programmers, whom I respected very much on the project I 
mentioned, was quite of the opposite view to mine.  He kept insisting
that one shouldn't *want* to know what a given property does.  He
used the example of a library package, where "clearly" I shouldn't
have to know about all the nitty-gritty details that go on under
the hood.

In the end, we found agreement based on one point: so long as one
cannot *trust* that the library is *bomb-proof, bug-free, fully 
documented code*, there's a good chance one needs to know what is 
going on underneath, especially to work around problems or even
just to figure out how to use the library.

I was of the opinion that we were not using, or creating, such
a library, and that therefore we had to insist on very limited
use of properties.

I guess I'm saying that the principle is sound, but practically I
have yet to see a situation where it would work for me.


More information about the Python-list mailing list