How can i compare a string which is non null and empty
Steven Howe
howe.steven at gmail.com
Mon Apr 2 16:48:30 EDT 2007
how about just testing it's length?
>>> from types import StringType
def stringTest(x):
... if type(x) == StringType:
... if len(x) == 0:
... print 'Empty String'
... else:
... print 'Not Empty String'
... else:
... print 'value not String Type'
...
lst = ['a','',5,(5,6),{'a':5}]
for item in lst:
... stringTest(item)
...
Not Empty String
Empty String
value not String Type
value not String Type
value not String Type
More information about the Python-list
mailing list