How can i compare a string which is non null and empty

tac-tics tactics40 at
Mon Apr 2 03:27:59 CEST 2007

str != ""

returns true if str is NOT the empty string.

str is not None

returns true if str is null (or None as it's called in python).

To check to make sure a string is nonnull and nonempty, do:

str is not None and str != ""

More information about the Python-list mailing list