How to destroy a Frame with condition

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Jun 27 01:40:30 EDT 2007


En Wed, 27 Jun 2007 01:39:22 -0300, senthil arasu <senwin30 at gmail.com>  
escribió:

> In my code logic I need to check the frame existence and then destroy a
> frame.
> I dont know how to code this  condition.
> In Python tutorials what i reffered, "if "condition given only for
> integers(like if x>0:)
>
> I need some one to help me.
>
> This is my condition
>
> If  iframe==NULL//if frame not available
>   iframe.destroy()

That does not look like Python code - and in any case, it does not make  
much sense. If iframe is NULL you can't call a method on it.
In Python, usually the symbol None is used when you want to say "nothing"  
(like NULL, null, or nil in another languages). But unlike other  
languages, None is an actual object - a singleton, there exist exactly one  
instance of it, that is, all references to None along the whole program  
refer to the same and unique object.
To test is something is None or anything else, you use the "is" operator.  
It tests object identity (whether both operands are in fact the same  
thing). Your code above (reversed) would be:

if iframe is not None:
     iframe.destroy()

This will call the destroy() method of iframe, only when iframe is not the  
None object itself.

-- 
Gabriel Genellina



More information about the Python-list mailing list