Advice needed on __del__

André Roberge andre.roberge at gmail.com
Tue May 10 06:22:21 EDT 2005


stasz wrote:
> On Mon, 09 May 2005 22:49:06 -0300, André Roberge wrote:
> 
> 
>>Scott David Daniels wrote:
>>
>>>André Roberge wrote:
>>>
>>>
>>>>...  Each time I refresh the screen, I could
>>>>force that call, then check to see if Evil has been
>>>>destroyed by Python, which would give me the information
>>>>I need to destroy Evil_twin behind the scene myself -
>>>>which is what I am really after.
> 
> Wouldn't it be better if the robots draw themselfs onto the canvas?
> That way you don't have to worry about deletion, a robot would only
> draw itself when he's has to.
> So perhaps it's an idea to delegate the drawing of stuff to the objects
> themself rather then in the 'visibleworld' class.
> 

I thought about doing something like this... but gave it up.  The other 
way works well.

> 
>>However (famous last words follow...) I feel it's not going to bite me
>>this time.  The main reason is that, when Evil is gone, before the
>>screen gets updated, lots of drawing calls and wxYield() calls are made,
>>so that __del__ has lots of time to get called.
> 
> Your relying on something that *will* bite you, the question is rather
> *when* will it bite you :-)
> 
Well, since
1) this is used only as a demonstration of scoping in Python, in one example
2) other examples do not involve the temporary creation of robots (i.e. 
they would never go out of scope)
3) it works so far...

I'll wait for someone telling me that demonstration doen't work for 
them. ;-)

> IMHO, the approach to rely on Python to do your dirty work and then
> checks if it's done seems a bit VB to me :-)
> 
Ouch!  You don't mince words, do you?  Trying to get the QOTW? ;-)
> 
> Stas Zytkiewicz
> 
Unless I am sorely mistaken, I believe *you* have a full copy of the 
source code.  Why don't you try and see if your approach can be 
incorporated in the program? I'll buy you a beer if you make it work! ;-)

André




More information about the Python-list mailing list