Empty dictionaries evaluate to False in Python:

>>> dct = {}
>>> bool(dct)
False
>>> not dct
True
>>>

Thus, your isEmpty function is unnecessary. All you need to do is:

def onMessage(self, socket, message):
    if not self.users:
        socket.send("Nobody is online, please use REGISTER command" \
                    " in order to register into the server")
    else:
        socket.send("ONLINE " + ' ' .join(self.users.keys()))
Answer from user2555451 on Stack Overflow
🌐
Medium
pavolkutaj.medium.com β€Ί how-to-check-if-a-list-dict-or-set-is-empty-in-python-as-per-pep8-35d8c64d07d0
How to Check if a List, Dict or Set is Empty in Python as per PEP8 | by Pavol Z. Kutaj | Medium
September 7, 2023 - duck typing means relying on general/conventional interfaces β†’ rather than explicitly checking for types β†’ you could argue that conventional interfaces are not magical, right Β· so something like if a == [] is forcing a particular type (() ...
🌐
DEV Community
dev.to β€Ί awesome_aj1298 β€Ί different-ways-to-check-if-object-is-empty-or-not-146
Different ways to check If Object is empty or not - DEV Community
September 18, 2020 - Checking if the Object is empty or not is quite a simple & common task but there are many ways to...
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί check-if-python-json-object-is-empty
Check If Python Json Object is Empty - GeeksforGeeks
July 23, 2025 - In this article, we explored three different methods to check if a JSON object is empty in Python.
🌐
Codedamn
codedamn.com β€Ί news β€Ί python
Python IsEmpty Function: A Detailed Guide
July 4, 2023 - When it comes to checking if a string is empty in Python, we can use similar methods as we did with sequences and collections. Just like with sequences and collections, the len() function can be used to check if a string is empty.
🌐
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
Learn how to check for None and empty values in Python. Discover the difference between None and empty strings/lists using the `is` operator and boolean context. Python None check, Python empty value check.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί how-to-check-if-variable-is-empty-in-python
How To Check If Variable Is Empty In Python? - GeeksforGeeks
July 23, 2025 - In this example, the code checks if the string variable `my_list` is empty by evaluating its truthiness.
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python-check-if-dictionary-is-empty
Check if dictionary is empty in Python - GeeksforGeeks
October 6, 2024 - It's common to need to check whether a set is empty in various programming scenariosPython# Initializing an empty set s = set() print(bool(s)) # False since the set is empty print(not bool(s)) # True since the set is empty
🌐
Java2Blog
java2blog.com β€Ί home β€Ί python β€Ί check if variable is empty in python
Check if Variable is Empty in Python [5 Ways] - Java2Blog
November 23, 2023 - Therefore, a simple boolean check with not operator can determine if a variable is empty. ... The not operator is a logical operator in Python that returns True if the expression to its right evaluates to False, and False if the expression evaluates ...
🌐
freeCodeCamp
freecodecamp.org β€Ί news β€Ί how-to-check-if-a-list-is-empty-in-python
Python isEmpty() equivalent – How to Check if a List is Empty in Python
April 19, 2023 - In the code above, we used an if statement and the not operator to check if the people_list was empty. You can use the len() function in Python to return the number of elements in a data structure.
🌐
PyTutorial
pytutorial.com β€Ί check-if-variable-is-empty-in-python
PyTutorial | How to Properly Check if a Variable is Empty in Python
February 29, 2020 - #empty variable var = "" #check if variable is empty if len(var) == 0: print("yes it is!")
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί python-check-if-nonetype-or-empty
Python Check if Nonetype or Empty - GeeksforGeeks
July 23, 2025 - In this example, the below Python code defines a list named `my_list` containing elements of different types (None, an empty string, and an integer). It then iterates through each element in the list using a for loop. For each element, it checks its type and prints a corresponding message. ... my_list = [None, '', 42] for item in my_list: if item is None: print(f"{item} is of NoneType") elif item == '': print(f"{item} is an empty string") else: print(f"{item} is neither None nor an empty string")
🌐
TutorialsPoint
tutorialspoint.com β€Ί how-to-check-if-a-list-is-empty-in-python
How to check if a list is empty in Python?
If the list is empty, then it returns True; otherwise, False, which means the list is not empty. The following program checks whether the input list is empty or not using the not operator - # empty list lst = [1,2,3,4,5] # evaluating empty list object to False if not lst: print('Empty list') else: print('List is not Empty \n',lst)
🌐
Enterprise DNA
blog.enterprisedna.co β€Ί python-check-if-list-is-empty-7-methods-explained
Python: Check If List is Empty (7 Methods Explained) – Master Data Skills + AI
This converts the list into a boolean value, which is True when the list has elements and False when the list is empty: my_list = [1, 2, 3] if bool(my_list): print("List contains items") The preferred method to test for an empty list is to use the not operator, as it exploits the implicit boolean ...
🌐
Codecademy Forums
discuss.codecademy.com β€Ί frequently asked questions β€Ί python faq
How can I determine if a dictionary is empty? - Python FAQ - Codecademy Forums
June 27, 2018 - Answer Yes, there are several ways to check if a dictionary is empty. The more standard Python method is to use a Boolean evaluation on the dictionary. An empty dictionary (or other containers) will evaluate to a Boolean False.