checking whether a var is empty or not
Dave Benjamin
ramen at lackingtalent.com
Wed Aug 4 01:52:32 EDT 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] -:- spoomusic.com -:- ramenfest.com ]:.
"When the country is confused and in chaos, information scientists appear."
Librarian's Lao Tzu: http://www.geocities.com/onelibrarian.geo/lao_tzu.html
More information about the Python-list
mailing list