[XML-SIG] 4DOM future

Paul Prescod paul@prescod.net
Wed, 03 Nov 1999 08:19:30 -0600


uche.ogbuji@fourthought.com wrote:
> 
> For instance, if we go with my leanings, which are towards an attribute-based
> approach, it would differ in a key way from PyDOM.  

I think that the attribute-based approach should be a short-cut for
get_parent and set_parent and get_parent/set_parent should be
optimizations for .parent. Years ago, I suggested that Python should
have special language features for declaring "computed properties"
because the __get__ hacks are slow and error prone. Maybe Python 2.

Anyhow, what's the contradiction with PyDom? It does both:

   def __getattr__(self, key):
        if key[0:4] == 'get_' or key[0:4] == 'set_':
            raise AttributeError, repr(key[4:])
        func = getattr(self, 'get_'+key)
        return func()

 Paul Prescod