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

Russ P. Russ.Paielli at gmail.com
Mon Jan 19 23:28:15 EST 2009


On Jan 19, 8:17 pm, Luis Zarrabeitia <ky... at uh.cu> wrote:
> Quoting "Russ P." <Russ.Paie... at gmail.com>:
>
>
>
>
>
> > On Jan 19, 6:24 pm, "James Mills" <prolo... at shortcircuit.net.au>
> > wrote:
>
> > > Python programmers tend to not have a need for
> > > properties. Quite honestly they are a waste of time.
> > > They come from traditional OO approaches to software design
> > > (and mostly from the Java world).
>
> > With statements like that, it's no wonder you don't understand the
> > value of encapsulation.
>
> [snip]
>
> > If you didn't plan ahead and encapsulate the radius from the start,
> > properties allow you to save yourself and encapsulate it later without
> > breaking the client's code.
>
> Python programmers don't _need_ to plan ahead and encapsulate the radius from
> the start. That's the whole point. No clairvoyance needed. I kind of like that.

And I like it too. I was trying to explain that to Mr. Mills, who
claimed that properties are "a waste of time."

Properties reduce the need for encapsulation, but they do not
eliminate it, particularly for large projects.

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.



More information about the Python-list mailing list