Re: [PyCrust] __setattr__ no longer strict
Brought to you by:
pobrien
|
From: Neil H. <ne...@sc...> - 2001-08-14 08:11:46
|
Kevin:
> class StaticLine( Widget ) :
> ...
> def _setLayout( self, aString ) :
> raise NotImplementedError
>
> def _getLayout( self ) :
> return self._layout
Python 2.2 will be introducing 'getset' attributes that will probably be
a better choice for widget attributes than using the __getattr__ and
__setattr__ hooks. They will look like this:
class StaticLine( Widget ) :
...
def _setLayout( self, aString ) :
raise NotImplementedError
def _getLayout( self ) :
return self._layout
layout = getset(_getLayout, _setLayout)
Python 2.2 may not be available for quite some time so its sensible to
stay with the current design for now. The getset feature is also best for
attributes that are defined statically for a class which is the case for
widgets but not for the set of components that are contained by a
background.
Neil
|