How can I test if a reference is null ?

smac apollo at aktv.lt
Thu Mar 27 20:01:09 CET 2003


cudjoe at europe.com (cudjoe) wrote in message news:<b1177e67.0303270740.34de715b at posting.google.com>...
> On a Java GUI, I need to test if a label contains an Icon, I wrote
> those few lines in Jython (similar):
> 
> 
> tabComp = panel.getComponents()
> trouve = false
> for com in tabComp:
>      if isinstance(com, JLabel):
>           icon = com.getIcon()
>           if( icon != NULL ): ##### doesn't work ! 
>                trouve = true
> 
> I know that there are no types in python, but how can we test if a
> variable is empty ?
> 
> Thanks you everybody,
> 
> Mathieu

if vars().has_key('icon'):
        print 'not empty'

---
Saulius




More information about the Python-list mailing list