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...
🌐
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.
🌐
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.
🌐
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
🌐
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.
🌐
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 ...
🌐
Python Central
pythoncentral.io β€Ί how-to-check-if-a-list-tuple-or-dictionary-is-empty-in-python
How to Check if a List, Tuple or Dictionary is Empty in Python | Python Central
December 29, 2021 - And we check each one again, this will be the result: [python] >>>is_empty(d) Structure is not empty. False [/python] As you can see, all the default data structures are detected as empty by treating the structure like a boolean in the if statement.
🌐
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)
🌐
Codecademy Forums
discuss.codecademy.com β€Ί frequently asked questions β€Ί python faq
How can I determine if a dictionary is empty? - Python FAQ - Codecademy Forums
June 22, 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.
🌐
datagy
datagy.io β€Ί home β€Ί python posts β€Ί python: check if a dictionary is empty (5 ways!)
Python: Check if a Dictionary is Empty (5 Ways!) β€’ datagy
December 20, 2022 - An interesting tidbit about Python dictionaries is that empty dictionaries will evaluate to False, while dictionaries with at least one item will evaluate to True. Because of this, we can use the bool() function to see if a dictionary is empty.