> How do you know that s is a string? It's a presumption based on the original problem statement. The example shown is a simple T/F check, which happens to determine the "emptiness" of strings. If type checking is absolutely necessary, one could use if isinstance(s, basestring): if s: print "not empty" else: print "empty"