[Pythonmac-SIG] Strange behavior with W

Gordon Worley redbird@rbisland.cx
Fri, 14 Jul 2000 18:56:38 -0400


At 7:56 PM +0100 7/14/2000, Just van Rossum wrote:
>At 9:20 PM -0400 13-07-2000, Gordon Worley wrote:
>>In a program I have, I first create a class that inherits from
>>W.Window and can be called Document for our purposes.  In the
>>Document, there is an instance of W.List called list.  Document
>>sometimes calls a class to edit items in this list called
>>List_Editor.  Among other things, List_Editor takes a Document object
>>as an argument.  When finishing up, the code that makes the change
>>looks something like this (note:  up in __init__, the passed Document
>>is put into self.document):
>>
>>self.document.list[index] = self.w.display.get()
>>
>>Which does what might be expected of it.  Yet this next line of code
>>will do the same thing:
>>
>>self.document.w.list[index] = self.w.display.get()
>>
>>Yet Document never creates any object called w, much less put
>>anything in it.  While I realize that complaining about my program
>>working isn't necessarily the best thing to do, this behavior, to me
>>at least, does not seem normal.  How can this be happening?
>
>So there should be no attribute called 'w'? Are you sure the Document class
>never assigns to self.w? The W.Window class certianly doesn't:

Yes I'm sure.

>  >>> import W
>>>>  w = W.Window((100, 100))
>>>>  w.open()
>>>>  w.w
>Traceback (innermost last):
>   File "<input>", line 1, in ?
>   File "DevDev:PyPy:Python  current:Mac:Tools:IDE:Wwindows.py", line 406,
>in __getattr__
>     raise AttributeError, attr
>AttributeError: w
>>>>
>
>Any chance you're playing with __getattr__? (W.Window does...)

Nope.

Actually, I just tried to reproduce this event again and it didn't 
work.  I get an AttribureError: w if I use the second line of code 
from above.  All I can figure is that restarting my computer did it 
(I restarted the IDE to see if it would still happen yesterday and it 
did, but today nothing).  Must have been some weirdness in the 
memory.  You know, those blocks just love to pick their own 
addresses.  ;-)
-- 
- Gordon Worley
http://www.rbisland.cx/
mailto:redbird@rbisland.cx