Empty string: Difference between revisions

Line 2,085:
 
=={{header|Python}}==
The empty string is printed by Python REPL as <nowiki>''</nowiki>, and is treated as boolean false (as are most empty container types, by convention). Any non-empty ''string'', including '0', is always treated as True in a boolean context.
Any non-empty ''string'', including '0', is always treated as True in a boolean context.
 
<lang python>s = ''
 
if not s or s == '':
print("String is empty")
 
if len(s) == 0:
print("String is empty")
else:
print("String not empty")</lang>
 
 
# boolean test function for python2 and python3
# test for regular (non-unicode) strings
# unicode strings
# None
def emptystring(str):
if isinstance(s, (''.__class__ , u''.__class__) ):
if len(str) == 0:
return True
else
return False
 
elif s is None:
return True
 
=={{header|Quite BASIC}}==