Yes, in Python 3.3 SimpleNamespace was added

Unlike object, with SimpleNamespace you can add and remove attributes. If a SimpleNamespace object is initialized with keyword arguments, those are directly added to the underlying namespace.

Example:

import types

x = types.SimpleNamespace()
x.happy = True

print(x.happy) # True

del x.happy
print(x.happy) # AttributeError. object has no attribute 'happy'
Answer from Vlad Bezden on Stack Overflow
🌐
TutorialBrain
tutorialbrain.com › home › python create object
Python Create Object — TutorialBrain
July 9, 2025 - Creating empty objects in Python is easy. Define an empty class and then create an object of that class.
Discussions

python - How to create an empty per object in selection? - Blender Stack Exchange
How can I create an empty / null / locator object using python? I'd like to create one for each selected object and then all empties should be parented or constraint to the selected objects, meanin... More on blender.stackexchange.com
🌐 blender.stackexchange.com
March 21, 2019
Custom Empty Object - Python API - Developer Forum
Hi all, I wonder if is possible to customize/write a new empty object Possibly I would like to be able to draw a Cylinder in the viewport and update is width and height in the viewport Something like the CylinderGizmo in 3dsmax How can I do this? with class should I look to write in the viewport? More on devtalk.blender.org
🌐 devtalk.blender.org
0
November 25, 2021
scripting - How to add empty object not using bpy.ops? - Blender Stack Exchange
0 How to get an object to display its actual position after transform using parenting with empty using python More on blender.stackexchange.com
🌐 blender.stackexchange.com
Accessing newly added empty object
Blender Artists is an online creative forum that is dedicated to the growth and education of the 3D software Blender. More on blenderartists.org
🌐 blenderartists.org
1
0
September 7, 2022
🌐
Reddit
reddit.com › r/learnpython › pass a list of empty objects to be initialized?
r/learnpython on Reddit: Pass a list of empty objects to be initialized?
February 16, 2021 -

I've spent a long time searching on how to do this and can't seem to crack it.

I have a series of objects that inherit from a parent object. The main differences between the subclasses of the parent are different model types for an ML project.

I have a couple of datasets I'd like to pass to init and run each of the models, for example, something like:

class Dtree(Supervised_Learning): 
      
      def __init__(self, features, labels): 
             super().__init__(features, labels)
             #other model init from sklearn here 


Models = [Dtree(), KNN(), Boosting(), SVM()]

def run_model(model, features, labels)

     mdl = model(features, labels)

     mdl.train()

     mdl.plot()

for model in Models:

     run_model(model)

I've tried just passing the name with out the () and then calling the class().__init___() methods with the features and labels vars, but I can't figure out how to pass the variable for self.

Anyway to do this? Or do I need to just code a function that explicitly inits all of the model objects?

🌐
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 ... ', 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....
🌐
W3Schools
w3schools.com › python › ref_func_object.asp
Python object() Function
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... The object() function returns an empty object.
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-create-an-empty-class-in-python
How to create an empty class in Python? - GeeksforGeeks
December 29, 2020 - # Python program to demonstrate # empty class class Geeks: pass # Driver's code obj = Geeks() print(obj) Output: <__main__.Geeks object at 0x02B4A340> Python also allows us to set the attributes of an object of an empty class. We can also set different attributes for different objects.
🌐
Adiyat Mubarak
adiyatmubarak.wordpress.com › 2017 › 03 › 06 › create-empty-object-in-python
Create Empty Object in Python – Adiyat Mubarak
March 6, 2017 - I need to create dummy object in python for testing purpose. Here is how to create dummy object in python on the fly using "type". Reference: http://stackoverflow.com/a/19476841/1936697
Find elsewhere
Top answer
1 of 2
4

Update for 2.8 +

import bpy

for obj in bpy.context.selected_objects:  # Loop over all selected objects
    empty = bpy.data.objects.new(obj.name + "_Empty", None)  # Create new empty object
    obj.users_collection[0].objects.link(empty)  # Link empty to the current object's collection
    empty.empty_display_type = 'PLAIN_AXES'
    empty.parent = obj

If you want the empties to be the parents :

import bpy

for obj in bpy.context.selected_objects:  # Loop over all selected objects
    empty = bpy.data.objects.new(obj.name + "_Empty", None)  # Create new empty object
    obj.users_collection[0].objects.link(empty)  # Link empty to the current object's collection
    empty.empty_display_type = 'PLAIN_AXES'
    empty.location = obj.location
    obj.parent = empty
    obj.location = (0, 0, 0)
2 of 2
2

bpy.ops.object.empty_add()

You can call bpy.ops.object.empty_add() operator per object and pass the location, rotation and scale for each object as well:

Blender 2.8+

import bpy

for obj in bpy.context.selected_objects:
    # Create the empty using the operator
    bpy.ops.object.empty_add(type='PLAIN_AXES', location=obj.location)
    # Get the newly created empty
    empty = bpy.context.view_layer.objects.active
    # Set the size
    empty.empty_display_size = 20
    # Parent the object to the empty
    obj.parent = empty

Blender 2.7x

import bpy

selected_objs = bpy.context.selected_objects
for obj in selected_objs:
    # Create the empty using the operator
    bpy.ops.object.empty_add(type='PLAIN_AXES', location=obj.location)
    # Get the newly created empty
    empty = bpy.context.scene.objects.active
    # Parent the object to the empty
    obj.parent = empty

I think it's quite straightforward, tell me if you have problems

🌐
CSDN
devpress.csdn.net › python › 62fd2ee5c677032930802ecb.html
Creating an empty object in Python - DevPress官方社区
August 18, 2022 - Edit: I mean an empty object usable for duck typing. You can use type to create a new class on the fly and then instantiate it.
🌐
Readthedocs
jfine-python-classes.readthedocs.io › en › latest › construct.html
Constructing classes — Objects and classes in Python tutorial
We will start with the empty class, which is not as empty as it looks. ... Like most Python objects, our empty class has a dictionary.
🌐
Blender Developer Forum
devtalk.blender.org › archive › python api
Custom Empty Object - Python API - Developer Forum
November 25, 2021 - Hi all, I wonder if is possible to customize/write a new empty object Possibly I would like to be able to draw a Cylinder in the viewport and update is width and height in the viewport Something like the CylinderGizmo…
🌐
pythontutorials
pythontutorials.net › blog › creating-an-empty-object-in-python
How to Create an Empty Object in Python: Shortcuts vs. Custom Classes for Duck Typing — pythontutorials.net
When to use: Never for empty objects. Use namedtuple only for fixed, immutable data. Python 3.7+’s dataclasses module simplifies class creation, but an empty dataclass is overkill for most empty object use cases.
🌐
Packtpub
subscription.packtpub.com › book › programming › 9781784398781 › 6 › ch06lvl1sec43 › empty-objects
6. Python Data Structures | Python 3 Object-oriented Programming
This new edition includes all the topics that made Python 3 Object-oriented Programming an instant Packt classic. It's also packed with updated content to reflect recent changes in the core Python library and covers modern third-party packages that were not available on the Python 3 platform when the book was first published. ... Let's start with the most basic Python built-in, one that we've seen many times already, the one that we've extended in every class we have created: the object.
🌐
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. Another use is to create a sort of flexible and lightweight “struct” … a container or data hub to ...
🌐
sqlpey
sqlpey.com › python › top-2-ways-to-create-an-empty-object-in-python
Top 2 Ways to Create an Empty Object in Python - sqlpey
November 23, 2024 - A: Yes, you can use SimpleNamespace or the type function to create empty objects dynamically, allowing flexibility in attribute management. Be sure to check out the following useful resources for further reading on Python programming:
🌐
Real Python
realpython.com › python-class-constructor
Python Class Constructors: Control Your Object Instantiation – Real Python
January 19, 2025 - To run the first step, Python classes have a special method called .__new__(), which is responsible for creating and returning a new empty object.