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
Discussions

Best way to do a "not None" test in Python for a normal and Unicode empty string? - Stack Overflow
Check the length of the returned value, and if it's an instance of unicode. ... # Works for normal empty strings <-- WRONG if string is not None: print "string is not an empty string." In Python 2.7.1, "" is not None evaluates to True - so string="" results in string is not an empty string ... More on stackoverflow.com
🌐 stackoverflow.com
Script Editor - If statement - String is NULL
Hi everybody, I needed to compare a string with NULL or see if the string is empty. 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, More on forum.inductiveautomation.com
🌐 forum.inductiveautomation.com
0
April 21, 2022
Python: String empty or null?
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 NULL and so there is no string value. How can I check both, if it is NULL or empty? More on community.openhab.org
🌐 community.openhab.org
0
February 25, 2021
What’s the cleanest way to do a python check if string is empty? - TestMu AI Community
I’m trying to figure out the most Pythonic way to handle a python check if string is empty. Right now, I’m doing this: if my_string == “”: It works, but I’m wondering if there’s a more elegant or built-in way, something like string.empty in other languages. More on community.testmuai.com
🌐 community.testmuai.com
0
July 3, 2025
🌐
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 - The not operator in the second example negates the "truthiness" or "falsiness" of the string, making the code slightly more concise. This is a common Pythonic way to check for empty strings. In Python, to check if a string is None, it's best practice to use the is operator rather than the == ...
🌐
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 - The string is empty. Explanation: A simple equality check (s == "") determines if the string is empty.
🌐
Sentry
sentry.io › sentry answers › python › check if a string is empty in python
Check if a string is empty in Python | Sentry
May 15, 2023 - 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 ...
🌐
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 - Using if not my_string: implicitly checks if the string is empty or evaluates to False. It’s a more idiomatic way to check for emptiness. Versatility: The if not my_string: approach works not only for empty strings but also for any falsy values.
🌐
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
In Python, you can check if a string is empty by using the 'not' operator as shown in the code above. You can also use the 'len' function that returns the number of characters in a string. If the number of characters is 0, then the string is empty. my_string = "" if len(my_string) == 0: ...
🌐
LabEx
labex.io › tutorials › python-how-to-check-if-a-value-is-none-or-empty-in-python-559594
How to Check If a Value Is None or Empty in Python | LabEx
We learned to check for None using the is operator and to check for emptiness in strings and lists using the if not condition, as empty strings and lists evaluate to False in a boolean context.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-check-if-nonetype-or-empty
Python Check if Nonetype or Empty - GeeksforGeeks
July 23, 2025 - In this example, below code processes a list `my_list` with elements (None, an empty string, and 42). It iterates through each item, printing whether it's of type None, an empty string, or neither.
🌐
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?
April 21, 2025 - Let's look at the following example, where we are going to use the basic way to check whether the string is empty or not. str1 = "" if not str1: print("It Is Empty.") else: print("It Is Not Empty.") ... The string is empty. The Python len() function is used to determine the length of an object ...
🌐
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,
🌐
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…
🌐
TestMu AI Community
community.testmuai.com › ask a question
What’s the cleanest way to do a python check if string is empty? - TestMu AI Community
July 3, 2025 - I’m trying to figure out the most Pythonic way to handle a python check if string is empty. Right now, I’m doing this: if my_string == “”: It works, but I’m wondering if there’s a more elegant or built-in way, somethi…
🌐
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 ...
🌐
Better Stack
betterstack.com › community › questions › how-to-check-if-string-is-empty-in-python
How to check if the string is empty in Python? | Better Stack Community
February 3, 2023 - To check if a string is empty in Python, you can use the len() function. For example: ... Alternatively, you can use the bool() function to check if the string is empty. An empty string is considered to be False, and all other strings are considered ...
🌐
Quora
quora.com › Does-Python-have-something-like-an-empty-string-variable-where-you-can-do-if-myString-string-empty-Regardless-whats-the-most-elegant-way-to-check-for-empty-string-values
Does Python have something like an empty string variable where you can do if myString == string.empty? Regardless, what's the most elegant way to check for empty string values? - Quora
Answer (1 of 3): I would test noneness before stripping. Also, I would use the fact that empty strings are False (or Falsy). This approach is similar to Apache's StringUtils.isBlank or Guava's Strings.isNullOrEmpty This is what I would use to test if a string is either None OR Empty OR Blank: [...
🌐
Syntax Scenarios
syntaxscenarios.com › python › check-if-a-string-is-empty
How to Check if a String is Empty in Python? – Syntax Scenarios
December 13, 2024 - In Python, it’s written as two quotes with nothing in between: "". On the other hand, a null string doesn’t exist at all, and a blank string might only appear empty but could contain spaces or invisible characters. ... This code shows three types of strings: an empty string (emptyString = ""), a string with spaces (blankString = " "), and a null value (nullString = None).
🌐
Medium
medium.com › @Hichem_MG › check-if-a-variable-is-not-none-in-python-3d6407798dec
Check if a variable is not None in Python | Medium
June 13, 2024 - Checking if a variable is truthy can mistakenly pass `0`, `False`, or empty collections. ... variable = 0 if variable: print("Variable is not None and is truthy") else: print("Variable is None or falsy") # Output: Variable is None or falsy · Always use `is not None` for explicit `None` checks to avoid confusion and ensure clarity in your code. Checking if a variable is not None is a fundamental practice in Python programming.