RE: [PyCrust] __setattr__ no longer strict
Brought to you by:
pobrien
|
From: Kevin A. <al...@se...> - 2001-08-14 07:48:15
|
Apologies, it is late and I hit return too early. That was supposed to go to Patrick, not the list, it is a PythonCard issue. ka > -----Original Message----- > From: pyc...@li... > [mailto:pyc...@li...]On Behalf Of Kevin > Altis > Sent: Tuesday, August 14, 2001 12:43 AM > To: pyc...@li... > Subject: [PyCrust] __setattr__ no longer strict > > > The attribute checks used to be strict, but now they're not. > > >>> comp.button1.bob = "hello" > > shouldn't be possible, since there is no 'bob' attribute. I found > this while > trying to decide how I was going to deal with attributes that can only be > set at initialization. What I came up with was to go ahead and > define a _get > and _set but have the _set method raise an exception. As an example, I > changed StaticLine and checked in widget.py. > > class StaticLine( Widget ) : > ... > def _setLayout( self, aString ) : > raise NotImplementedError > > def _getLayout( self ) : > return self._layout > > So, then I tried: > > >>> comp.staticlineH.layout > 'horizontal' > >>> comp.staticlineH.layout = 'bob' > > The layout = 'bob' should throw an exception, but it doesn't for some > reason?! I tried this standalone in proof.py and in the shell and got the > same results. I added a _setName to the Widget class that does the same > NotImplementedError. > > Maybe your original was better before we were trying to get the > self._magicGetPrefix to work?! > > On a lighter note, it is sort of fun to define toolTips on the fly. > > comp.button1.toolTip = 'Hello World' > > And I sure do like not have _ and __ show up anymore. > > ka > > > _______________________________________________ > PyCrust-users mailing list > PyC...@li... > http://lists.sourceforge.net/lists/listinfo/pycrust-users > |