Null String Variable

Peter Hansen peter at engcorp.com
Mon May 16 19:06:51 EDT 2005


Sean McIlroy wrote:
> well, somebody's already pointed out that bool(msg)==False iff msg==''.

I may not have received the message yet, but if "iff" still means "if 
and only if", then that statement is wrong.  There are, of course, about 
a dozen things for which bool(msg) is False when msg != '', not 
including the possibility of objects that define their bool state 
however they want.

> i'm curious to know what's wrong with simply writing
> 
> if msg=='':
>     ## do_something

I'm not sure anything is wrong with it in this case, though the idiom in 
Python is generally to do just "if not msg" unless you're concerned 
about the possibility that msg is not actually a string.

-Peter



More information about the Python-list mailing list