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

Jonathan P. jbperez808 at yahoo.com
Sun Jan 19 20:15:36 EST 2003


>From PEP 8:

Designing for inheritance

  ...  It's almost always preferrable to give a 
  functional interface to your class instead (and 
  some Python 2.2 developments will make this 
  much nicer)...

Do properties (what I believe is being referred to
by the phrase 'some Python 2.2 developments') count
as a functional interface?  Their usage is identical
to public variables/attributes, so I have to disagree.
    
I have yet to be fully convinced that accessor 
functions (and now, properties) are a good
abstraction.  I'm very uncomfortable about the 
idea of properties allowing side effects.  I
can't help but feel that they are yet another 
addition to that mess of conceptual kludges known 
as OOP.  OOP seems to have much less of a solid
theoretical foundation than the relational or
functional models and it shows in all the annoying
complexity you see in most OOP languages.  I
wonder if studying Smalltalk can yield some OOP
wisdom.  OOP was originally only about message
passing between objects, but it has strayed from 
the path of its (purported) initial simplicity.
( guess who/which language is to blame ;-) )

I believe that Python's language design is such 
that direct usage of 'public variables' is 
not a bad practice at all.  I'm currently building
a fairly complex class library and should be in a 
position to prove/disprove this to myself.




More information about the Python-list mailing list