checking whether a var is empty or not

Dave Benjamin ramen at
Wed Aug 4 07:52:32 CEST 2004

In article <opsbxubr1g1v4ijd at musicbox>, Pierre-Frédéric Caillaud wrote:
> 	This smells like PHP to me...
> if var is not None:
> 	if var has not been assigned, it raises an exception.
> 	if var has been assigned, it contains a value which can be None or  
> someting else.
> 	This is different from PHP where you can't know if a variable exists or  
> not, because a non-existent variable will contain null if you check it,  
> and putting null in a variable is like deleting it, but noone knows  
> because there's no way of checking if a variable really exists, etc.

No, in PHP, you can find out if a variable exists using isset(). And trying
to dereference an uninitialized variable will generate a warning if you have
error reporting turned up all the way (error_reporting(E_ALL)).

  .:[ dave benjamin: ramen/[sp00] -:- -:- ]:.

"When the country is confused and in chaos, information scientists appear."
Librarian's Lao Tzu:

More information about the Python-list mailing list