[Zope3-dev] style: property(getX, setX) vs. explicit getters and setters

Gary Poster garyposter@earthlink.net
Tue, 18 Jun 2002 16:50:30 -0400


With 2.2, of course, we have the ability to define a given pair of getter and 
setter as if they were a simple property.  What is the Zope3 style opinion on 
this?  

to clarify--let's say I have some special functionality I want to implement 
when setting the property "factoryId".  Old style for me would be to build out

  def getFactoryId(self):
and
  def setFactoryId(self, id):

Some folks like

  def factoryId(self)
and
  def setFactoryId(self, id)

but same difference.

I think I prefer, at least in this example that has details I'm not boring 
you with,

  def __getFactoryId(self):
  def __setFactoryId(self,id):
  factoryId=property(__getFactoryId, __setFactoryId)

What do other folks think?  What if one of those functions might raise an 
error--would that make a difference in your opinion?  Any other special 
circumstances?  Is the property trick slower?

Thanks

Gary