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

John Roth johnroth at ameritech.net
Fri Jan 17 16:30:20 EST 2003


"Laura Creighton" <lac at strakt.com> wrote in message
news:mailman.1042815692.24240.python-list at python.org...
>
> Peter Hansen wrote:
> >
> > I rebelled against this at the time, almost outlawing properties,
> > because it got to the point where I couldn't tell when something
> > was just setting a value, possibly with a check or clipping or
> > something applied, and when the code -- which looked like a simple
> > assignment -- was actually storing some data in a file, sending
> > a message to another thread, stopping the machine's motion, and
> > then launching a Space Shuttle.
> >
> > No doubt forbidding them was an overreaction, but at least it
> > let us start getting a handle on the complexity of the code.
>
> > I've been looking forward to having a chance to let them redeem
> > themselves when I start using them with Python... if they can.
> > Do they really enhance clarity and maintenance, or might they be
> > more _in the way_ of easy comprehension?
>
> This is a judgement call based on what level of abstaction you want
> for the solving of your problem.  Do you want any of your programmers
> to _care_ that what really happens when a state changes is 'store some
> data in a file, send a message to another thread ....'?  If their
> reaction is 'we're mathematicians, don't talk to us about hardware'
> then they may be absolutely correct.

I don't think any library exists that is that clean in the real world.
I certainly have never encountered one that hasn't, at some point,
turned around and bit me because the library's assumptions didn't
match my understanding.

John Roth
>
> Laura Creighton
>






More information about the Python-list mailing list