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 - # Python program to demonstrate # empty class class Employee: pass # Driver's code # Object 1 details obj1 = Employee() obj1.name = 'Nikhil' obj1.office = 'GeeksforGeeks' # Object 2 details obj2 = Employee() obj2.name = 'Abhinav' obj2.office = 'GeeksforGeeks' obj2.phone = 1234567889 # Printing details print("obj1 Details:") print("Name:", obj1.name) print("Office:", obj1.office) print() print("obj2 Details:") print("Name:", obj2.name) print("Office:", obj2.office) print("Phone:", obj2.phone) # Uncommenting this print("Phone:", obj1.phone) # will raise an AttributeError
Discussions

[Python] What's a empty object and user-defined method objects?
Myclass.func is a function, but you can't call it. Try it: Myclass.func() # TypeError Why not? Because a class's functions must be called in the context of some particular instance of the class. Why? Well, here's an example: class Animal: def __init__(self, sound): self.sound = sound def speak(self): print('%s', self.sound) dog = Animal('woof') cat = Animal('meow') speakFunction = Animal.speak speakFunction() What is that last line supposed to do? Does it woof? Does it meow? We don't know. We didn't specify which instance of Animal we wanted to invoke. Put another way, that method isn't bound to any particular instance of Animal. But what does THIS do? speakFunction = dog.speak speakFunction() That one works! Why? Because we specified that we wanted the one that says 'woof.' We could also do it this way: speakFunction = Animal.speak speakFunction(dog) Okay, now to answer your questions explicitly. An "empty object" is a newly-created instance in a class that doesn't do any initialization. It has no custom fields set to any values beyond what any Python class instance would have. It's empty in the non-technical, English sense of the word. A user-defined function is what it says on the tin. It's a function, defined by some Python code. Example: def foo(): print("I'm a user-defined function!") Its name is only relevant when comparing it to other, more complicated types of things that can be called in Python, like instance methods, generators, built-ins, classes, and more. More on reddit.com
🌐 r/learnprogramming
4
2
January 22, 2019
python - Why empty function are needed - Software Engineering Stack Exchange
All you can do in that case is supply an empty callback routine. (Yes, I have a particular vendor in mind.) ... John R. Strohm Β· 18.2k66 gold badges4949 silver badges5656 bronze badges 2 Β· I used pass a lot as a placeholder when writing code, particularly in classes, when I want something runnable before everything is complete. It is really python... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
January 13, 2015
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
How can I create an empty list?
Answer There are two ways to create an empty list in Python. The most direct way is to create a variable and assign it an empty list by using a set of square brackets ([]) containing no items. The second way to create an empty list is to use the list class to create an empty list. More on discuss.codecademy.com
🌐 discuss.codecademy.com
0
16
July 26, 2018
🌐
TutorialsPoint
tutorialspoint.com β€Ί article β€Ί how-to-create-an-empty-class-in-python
How to create an empty class in Python?
September 15, 2022 - The attributes are data members (class variables and instance variables) and methods, accessed via dot notation. We can easily create an empty class in Python using the pass statement.
🌐
Python documentation
docs.python.org β€Ί 3 β€Ί tutorial β€Ί classes.html
9. Classes β€” Python 3.14.4 documentation
The instantiation operation (β€œcalling” a class object) creates an empty object. Many classes like to create objects with instances customized to a specific initial state.
🌐
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.
🌐
W3Schools
w3schools.com β€Ί PYTHON β€Ί python_classes.asp
Python Classes
... 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.
Find elsewhere
🌐
Reddit
reddit.com β€Ί r/learnprogramming β€Ί [python] what's a empty object and user-defined method objects?
r/learnprogramming on Reddit: [Python] What's a empty object and user-defined method objects?
January 22, 2019 -

https://docs.python.org/3/tutorial/classes.html#class-objects

They say calling a class object creates a empty object, what's that?

https://docs.python.org/3/reference/datamodel.html

Under Callables, under Instance Methods

They were talking about user-defined methods objects are created if I get a attribute from a class (or instance of it) that's a user defined function or class method object.

But isn't MyClass.func a function and not a method

class Myclass:

  def func(self): pass

print(Myclass.func) # function

print(Myclass().func) #bounded method

So what's a user defined method object?

Top answer
1 of 2
3
Myclass.func is a function, but you can't call it. Try it: Myclass.func() # TypeError Why not? Because a class's functions must be called in the context of some particular instance of the class. Why? Well, here's an example: class Animal: def __init__(self, sound): self.sound = sound def speak(self): print('%s', self.sound) dog = Animal('woof') cat = Animal('meow') speakFunction = Animal.speak speakFunction() What is that last line supposed to do? Does it woof? Does it meow? We don't know. We didn't specify which instance of Animal we wanted to invoke. Put another way, that method isn't bound to any particular instance of Animal. But what does THIS do? speakFunction = dog.speak speakFunction() That one works! Why? Because we specified that we wanted the one that says 'woof.' We could also do it this way: speakFunction = Animal.speak speakFunction(dog) Okay, now to answer your questions explicitly. An "empty object" is a newly-created instance in a class that doesn't do any initialization. It has no custom fields set to any values beyond what any Python class instance would have. It's empty in the non-technical, English sense of the word. A user-defined function is what it says on the tin. It's a function, defined by some Python code. Example: def foo(): print("I'm a user-defined function!") Its name is only relevant when comparing it to other, more complicated types of things that can be called in Python, like instance methods, generators, built-ins, classes, and more.
2 of 2
2
They say calling a class object creates a empty object, what's that? They are just saying that unless you define an init method to set the initial value of class variables, they will not have values assigned and thus is an "empty" object.
Top answer
1 of 4
4

In shell languages of the Bourne family, the : command, which does nothing at all, is typically used in two situations:

  • Placeholder for when something expects a mandatory command, e.g.

    while some_condtion
    do :
    done
    

    since do requires at least one command.

  • Discarding the arguments, but performing side effects inside the argument list, e.g.

    : ${myvar=foo}
    

I'm sure there are probably other applications that shell experts would know :)

In Python (and other languages) it's used less frequently. It can act as an argument to a higher-order function when you don't actually want to do anything. For example, say you have a function that submits a form and allows an function to be called asynchronously after submission is complete:

def submit(callback=empty_func):
    ...

This way, if the callback is not provided, the submission will still go through but no further actions will be performed. If you had used None as the default value, you'd have to explicitly check whether the callback was None, adding clutter to the code.

2 of 4
0

Rufflewind did a good job covering when you might use an empty function in a completed program. In my experience, it tends to be used more often in unfinished programs, so you can plan out what you're going to write and have it still compile until you get around to actually implementing it. In other words, it's usually just a placeholder.

It's necessary in python's case because it uses indentation to mark blocks, unlike C-like languages who use braces {}. This means if you didn't have pass, the parser couldn't tell if you meant to leave it empty or if you forgot. Including pass makes the parser much simpler, and gives you a convenient word to search for when you're looking for unimplemented blocks.

🌐
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.
🌐
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
One of the simplest ways to create an empty class in Python is by using the pass statement. It serves as a placeholder, signifying that the block of code is intentionally left blank.
🌐
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

🌐
Built In
builtin.com β€Ί software-engineering-perspectives β€Ί define-empty-variables-python
How to Define Empty Variables and Data Structures in Python | Built In
An empty variable in Python is a variable with no assigned value, often used as a placeholder in the code for a missing value. Empty variables can be defined using the None keyword (like a = None) or by leaving syntax as empty (like a_list = []).
🌐
Codecademy Forums
discuss.codecademy.com β€Ί frequently asked questions β€Ί python faq
How can I create an empty list? - Python FAQ - Codecademy Forums
July 26, 2018 - The most direct way is to create a variable and assign it an empty list by using a set of square brackets ([]) containing no items. The second way to create an empty list is to use the list class to create an empty list.
🌐
YouTube
youtube.com β€Ί innovate yourself
Create an Empty class in Python πŸ’₯ #class #object #python #youtubeshorts #subscribe #programming - YouTube
AboutPressCopyrightContact usCreatorsAdvertiseDevelopersTermsPrivacyPolicy & SafetyHow YouTube worksTest new features Β· Β© 2024 Google LLC
Published Β  February 29, 2024
Views Β  434
🌐
Duke
fintechpython.pages.oit.duke.edu β€Ί jupyternotebooks β€Ί 1-Core Python β€Ί answers β€Ί rq-25-answers.html
Core Python / Classes and Objects β€” Programming for Financial Technology
Why is creating an empty class useful? In Python, you can create an empty class by defining a class without any attributes or methods.
🌐
Dataquest
dataquest.io β€Ί blog β€Ί using-classes-in-python
Step-by-Step Python Tutorial: What are Python Classes and How Do I Use Them? (2022) – Dataquest
February 16, 2026 - Learn Python classes with clear examples. Understand constructors, instance variables, inheritance, and OOP basics. Perfect guide for beginners.
🌐
Python documentation
docs.python.org β€Ί 3 β€Ί reference β€Ί datamodel.html
3. Data model β€” Python 3.14.4 documentation
The default implementation by the object class should be given an empty format_spec string.
🌐
HackerEarth
hackerearth.com β€Ί practice β€Ί python β€Ί object oriented programming β€Ί classes and objects i
Classes and Objects I Tutorials & Notes | Python | HackerEarth
An object is created using the constructor of the class. This object will then be called the instance of the class. In Python we create instances in the following manner ... The simplest class can be created using the class keyword. For example, let's create a simple, empty class with no functionalities.