A class is more or less a fancy wrapper for a dict of attributes to objects. When you instantiate a class you can assign to its attributes, and those will be stored in foo.__dict__; likewise, you can look in foo.__dict__ for any attributes you have already written.

This means you can do some neat dynamic things like:

class Employee: pass
def foo(self): pass
Employee.foo = foo

as well as assigning to a particular instance. (EDIT: added self parameter)

Answer from Katriel on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-create-an-empty-class-in-python
How to create an empty class in Python? - GeeksforGeeks
July 12, 2025 - File "gfg.py", line 5 ^ SyntaxError: unexpected EOF while parsing In Python, to write an empty class pass statement is used. pass is a special statement in Python that does nothing.
Discussions

What's the usage of empty class in Python - Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... We can create an empty class using pass statement in Python. More on stackoverflow.com
๐ŸŒ stackoverflow.com
Can you create a class with an empty list attribute
what should I do to work around this? When you initialize the object, set the attribute to an empty list. More on reddit.com
๐ŸŒ r/learnpython
7
1
February 22, 2023
oop - Creating an empty object in Python - Stack Overflow
Find centralized, trusted content ... you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Are there any shortcuts for defining an empty object in Python or do you always have to create an instance of a custom empty class... More on stackoverflow.com
๐ŸŒ stackoverflow.com
April 22, 2019
Does there exist empty class in python? - Stack Overflow
But of course, if you donโ€™t need its few features, a simple class Empty: pass does just the same. ... @maggot092 And as I have said, you can easily add the implementation to your Python 2 project and use it as if it was thereโ€ฆ More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Quora
quora.com โ€บ Why-would-you-want-to-have-an-empty-class-in-Python
Why would you want to have an empty class in Python? - Quora
Answer (1 of 2): The most common case is for defining your own custom exceptions. Those are normally empty classes inheriting from the most appropriate existing exception in the hierarchy.
๐ŸŒ
Finxter
blog.finxter.com โ€บ 5-best-ways-to-create-an-empty-class-in-python
5 Best Ways to Create an Empty Class in Python โ€“ Be on the Right Side of Change
This not only defines the empty class but also provides a description of the classโ€™s intended use. ... class EmptyClass: """This is an empty class that may be expanded later.""" print(EmptyClass) print(EmptyClass.__doc__) ... The docstring inside the class serves as a stand-in for the class body, effectively creating an empty class while also providing information about it. The second print function outputs the docstring itself. Python allows for the declaration of a class without using pass, ellipsis, or a docstring, thanks to its relaxed syntax rules.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-create-an-empty-class-in-python
How to create an empty class in Python?
September 15, 2022 - class Student: pass # Creating objects st1 = Student() st1.name = 'Henry' st1.age = 17 st1.marks = 90 st2 = Student() st2.name = 'Clark' st2.age = 16 st2.marks = 77 st2.phone = '120-6756-79' print('Student 1 = ', st1.name, st1.age, st1.marks) print('Student 2 = ', st2.name, st2.age, st2.marks, st2.phone) Student 1 = Henry 17 90 Student 2 = Clark 16 77 120-6756-79 ยท Using the pass statement, we can also create empty functions and loops.
Top answer
1 of 2
3

When you create a new class, you are creating a new type. This newly created type may have some properties, or may not. These properties allow to hold data, methods etc.

Empty class that doesn't inherit any base class would be useful as placeholder.

class ServiceWrapper(object):
    pass

def sendMessage(svc:ServiceWrapper):
    #do something
    #pass

On the other hand, empty classes that inherit other classes is a very common pattern. Specially when defining user exceptions.

class Networkerror(RuntimeError):
    pass

try:
    raise Networkerror()
except Networkerror:
    #do something
    #pass

Also recently, the python collections.abc allows creating interface like functionalities.

class ServiceWrapper(ABC):
    @abstractmethod
    def send(self):...

def sendMessage(svc:ServiceWrapper):
    svc.send()
    #pass
2 of 2
0

I recently found myself using empty Python classes as unique "tags" for an observer system.

For example, something like this...

from collections import defaultdict

class OnCreate:
    pass

class OnModify:
    pass

class OnDelete:
    pass

class ObserverSystem:
    def __init__(self):
        self.observers = defaultdict(list)

    def register(self, event, callback):
        self.observers[event].append(callback)

    def notify(self, event, *args, **kwargs):
        for callback in self.observers[event]:
            callback(*args, **kwargs)

observer = ObserverSystem()
observer.register(OnCreate, lambda entity: print(f"Entity {entity} created"))
observer.register(OnModify, lambda entity: print(f"Entity {entity} modified"))
observer.register(OnDelete, lambda entity: print(f"Entity {entity} deleted"))

observer.notify(OnCreate, 1)
observer.notify(OnModify, 2)
observer.notify(OnDelete, 3)

I guess, I could have used a of numeric value, or even a string as the "tag", but the class is unique, it's hashable so I can use it as dict key, etc. Seems to work well.

๐ŸŒ
BioChemiThon
biochemithon.in โ€บ home โ€บ python | how to create an empty class?
Python | How to Create an Empty Class? - BioChemiThon
August 15, 2023 - It is common to create empty classes when you are defining a class that you plan to fill in later with properties and methods. This allows you to create the class skeleton with the appropriate class name and inheritance (if needed) without needing to define any properties or methods immediately.
Find elsewhere
๐ŸŒ
CodingNomads
codingnomads.com โ€บ creating-python-objects-from-classes
Python Classes, Objects and Instance Variables
In this code snippet, you've defined an empty class. Then, you created an instance of that empty class.
๐ŸŒ
Readthedocs
jfine-python-classes.readthedocs.io โ€บ en โ€บ latest โ€บ construct.html
Constructing classes โ€” Objects and classes in Python tutorial
Like most Python objects, our empty class has a dictionary. The dictionary holds the attributes of the object. ... Even though our class is empty, its dictionary (or more exactly dictproxy) is not.
๐ŸŒ
Studyzone4u
studyzone4u.com โ€บ post-details โ€บ how-to-define-an-empty-class-in-python
How to define an empty class in python - studyzone4u.com
November 21, 2025 - class A: pass # define object obj = A() print(obj) # set an attribute of the object for the empty class obj.title = 'Empty Class' print(obj.title) ... >>> ===================== RESTART: E:\py\empty_class.py ===================== <__main__.A object at 0x000002B88AEA4788> Empty Class ยท Python Multithreading: A Complete Guide for Developers
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ can you create a class with an empty list attribute
r/learnpython on Reddit: Can you create a class with an empty list attribute
February 22, 2023 -

I'm trying to create texas holdem with players being class instances with hand as an attribute of type list. When I instantiate a class with no value for hand it says I need instantiate it with a list, and when I try to use self.hand = None it doesn't allow me to append new generated cards to it since it's value type none, what should I do to work around this?

Edit: Now that I'm home I can add my code for people to see

Main Code

from pokerMethods import *
from playerClass import *

def main():
    deckNumber = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
    deckSuit = ["Spades", "Diamonds", "Clubs", "Hearts"]
    cardList = []
    playerList = []
    p1 = Player("Herp", "Derp")
    p2 = Player("Herpy", "Derpy")

    createCard(p1, deckNumber, deckSuit, cardList)
    createCard(p2, deckNumber, deckSuit, cardList)
    
    print(p1.hand)
    print(p2.hand)
main()

Class Code:

class Player:
    def __init__(self, fname: str, lname: str, hand = [], money = 0):
        self.fname = fname
        self.lname = lname
        self.hand = hand
        self.money = money

    def addCard(self, newCard):
        self.hand.insert(0,newCard)

    def removeMoney(self, bet):
        self.money -= bet

    def addMoney(self, bet):
        self.money += bet

Method Code

import random
def createCard(player, deckNumber, deckSuit, cardList,):
    cardPlayer = deckNumber[random.randint(0, len(deckNumber)-1)] + " " + 
    deckSuit[random.randint(0, len(deckSuit)-1)]
    if cardPlayer not in cardList:
        cardList.append(cardPlayer)
        player.addCard(cardPlayer)

added hand = [] and then did self.hand = hand because when I did just self.hand = [] it gave me the error

Traceback (most recent call last):

File "Pythons Test Shit\Test'.py", line 17, in <module>

main()

File "Pythons Test Shit\Test'.py", line 9, in main

p1 = Player("Herp", "Derp")

TypeError: __init__() missing 1 required positional argument: 'hand'

and with hand = [] in the initializer

Player 1: ['2 Hearts', '1 Clubs']

Player 2: ['2 Hearts', '1 Clubs']

both instances are having their lists edited

edit 2:

re-read the comments and saw u/Binary101010 's comment, sorry for not trying that before doing all my edits and stuff but thank you so much, it worked

๐ŸŒ
PyQuestHub
pyquesthub.com โ€บ creating-empty-classes-in-python-a-beginners-guide
Creating Empty Classes in Python: A Beginner's Guide
November 21, 2024 - It serves as a basic building block in object-oriented programming (OOP) and can be useful for various purposes like creating data structures or as a placeholder for future development. ... In this example, we define an empty class named EmptyClass using the class keyword followed by the class name.
๐ŸŒ
CopyProgramming
copyprogramming.com โ€บ howto โ€บ how-to-create-an-empty-class-in-python
Python: Creating an Empty Class in Python: A Step-by-Step Guide
August 18, 2023 - To create an empty class in Python, the pass statement is utilized. This particular statement is considered special because it serves no purpose other than being a placeholder. It is worth noting that instances of an empty class can still be instantiated.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_classes.asp
Python Classes/Objects
Almost everything in Python is an object, with its properties and methods. A Class is like an object constructor, or a "blueprint" for creating objects. ... Note: Each object is independent and has its own copy of the class properties. class definitions cannot be empty, but if you for some reason have a class definition with no content, put in the pass statement to avoid getting an error. ... If you want to use ...
๐ŸŒ
Intellipaat
intellipaat.com โ€บ community โ€บ 70671 โ€บ empty-class-object-in-python
Empty class object in Python - Intellipaat Community
I'm actually teaching a Python class on OOP and as I'm catching up on the most proficient method ... , however, is there another method of doing it?
Published ย  February 16, 2021