Empty strings are "falsy" (python 2 or python 3 reference), which means they are considered false in a Boolean context, so you can just do this:

if not myString:

This is the preferred way if you know that your variable is a string. If your variable could also be some other type then you should use:

if myString == "":

See the documentation on Truth Value Testing for other values that are false in Boolean contexts.

Answer from Andrew Clark on Stack Overflow
🌐
Inductive Automation
forum.inductiveautomation.com › ignition
Script Editor - If statement - String is NULL - Ignition - Inductive Automation Forum
April 21, 2022 - I tried the python function .isNull() >> doesn’t works. I tried isNull(string_to_compare) >> doesn’t works. Finally I founded: if (string_to_compare == None): else: Trying to help,
🌐
CodeSpeedy
codespeedy.com › home › how to check if a string is null in python
How to check if a string is Null in Python - CodeSpeedy
February 4, 2020 - We can check if a string is Null in Python using two different methods. We can use either isspace() function or we can use len() function.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-program-to-check-if-string-is-empty-or-not
Check if String is Empty or Not - Python - GeeksforGeeks
July 11, 2025 - Explanation: A simple equality check (s == "") determines if the string is empty. The len() function returns the length of a string so if the length is 0, it means that string is empty: ... The string is empty.
🌐
Stack Abuse
stackabuse.com › how-to-check-if-a-string-is-empty-or-none-in-python
How to Check if a String is Empty or None in Python
June 5, 2023 - We'll use an or operator to check both conditions at once: s = "" # Try also with s = None if s is None or s == "": print("String is empty or None") else: print("String is not empty and not None") Advice: Find out more about the or operator in Python by reading our "Guide to the Python or Operator".
🌐
Sentry
sentry.io › sentry answers › python › check if a string is empty in python
Check if a string is empty in Python | Sentry
if my_string.strip() == "": print("my_string is an empty string!") else: print("my_string is not an empty string!") Sentry BlogPython Performance Testing: A Comprehensive Guide (opens in a new tab) Syntax.fmListen to the Syntax Podcast (opens in a new tab) Sentry BlogLogging in Python: A Developer’s Guide (opens in a new tab)
🌐
Esri Community
community.esri.com › t5 › python-questions › quot-if-not-null-and-not-empty-string-quot-paradox › td-p › 1618009
Solved: "If not Null and not empty string" paradox - help ... - Esri Community
May 29, 2025 - Your original logic is also evaluating to True if the sate is both None and not an empty string (which is always True) ... From both a practice ( https://peps.python.org/pep-0008/ ) and performance perspective, checking for None should be done using "is" or "is not".
Find elsewhere
🌐
PythonHow
pythonhow.com › how › check-if-a-string-is-empty
Here is how to check if a string is empty in Python
The 'not' operator returns True if the string is empty and False if it is not. ... In Python, you can check if a string is empty by using the 'not' operator as shown in the code above.
🌐
openHAB Community
community.openhab.org › setup, configuration and use › scripts & rules
Python: String empty or null? - Scripts & Rules - openHAB Community
February 25, 2021 - Hey guys, one maybe very easy question: I try to check if a string item is empty, therefore I try it with: if len(ir.getItem(presenceLightAlter).state.StringValue()) > 0: But I get an error, because the item state is…
🌐
Javaexercise
javaexercise.com › python › check-string-null-in-python
How To Check If String Is Null In Python - Javaexercise
# Take a String str = "" # Check whether it is empty if not str: print("string is empty") else: print("string is not empty") ... If a string contains blank spaces that do not make sense and treated as a null string.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › check if string is empty or not in python
Check if String is Empty or Not in Python - Spark By {Examples}
May 21, 2024 - You can use the if not my_string: syntax to check if a string is empty. This evaluates to True if the string is empty. Are there other ways to check for an empty string? There are additional ways to check for an empty string in Python.
🌐
Edureka Community
edureka.co › home › community › categories › python › how to check if a string is null in python
How to check if a string is null in python | Edureka Community
August 20, 2018 - This question already has an answer here: Most elegant way to check if the string is empty in ... is the variable in which the value is stored.
🌐
TutorialsPoint
tutorialspoint.com › what-is-the-most-elegant-way-to-check-if-the-string-is-empty-in-python
What is the most elegant way to check if the string is empty in Python?
In the following example, we are going to check whether the string is empty or not by using the equality comparison. x = "" if x == "": print("The string is empty.") else: print("It Is Not Empty.") The following is the output of the above program - The string is empty. The Python strip() method is used to remove all the specified leading and trailing characters from the beginning and end of the string.
🌐
AskPython
askpython.com › home › 4 methods to check whether a string is empty in python
4 Methods to Check Whether a String Is Empty in Python - AskPython
February 27, 2022 - str1 = "" str2 = " " if(not (str1 and str1.strip())): print ("Yes the string is empty") else : print ("No the string is not empty") if(not(str2 and str2.strip())): print ("Yes the string is empty") else : print ("No the string is not empty") ...
🌐
Squash
squash.io › how-to-check-for-an-empty-string-in-python
How to Check for an Empty String in Python
We use an if-else statement with the not operator to check if string is empty. If it is, we print "The string is empty"; otherwise, we print "The string is not empty". Related Article: Python Command Line Arguments: How to Use Them
🌐
Quora
quora.com › How-do-I-check-if-the-string-is-empty-in-Python
How to check if the string is empty in Python - Quora
Answer (1 of 15): You can check it with a very simple if execution. Let us say, if you want to check pure empty string (must not contain even whitespaces), then you can do just like below: [code]if not string: print("Empty") [/code]Or, if you want to consider string with no character (but may ...
🌐
Studytonight
studytonight.com › post › how-to-check-for-an-empty-string
How to check if string is empty in Python? - Studytonight
May 3, 2023 - It is denoted by two quotes with nothing in between them: "". You can check if a string is empty in Python using the not operator, which returns True if the string is empty and False otherwise.