Quick search gave me this result:
This is supposedly a module that will allow you to create and modify DXF files.
Should be better solution.
simple example of deleting all points in dxf file:
import sys
import ezdxf
try:
doc = ezdxf.readfile("points_.dxf")
except IOError:
print(f"Not a DXF file or a generic I/O error.")
sys.exit(1)
except ezdxf.DXFStructureError:
print(f"Invalid or corrupted DXF file.")
sys.exit(2)
model_space = doc.modelspace()
for e in model_space:
if e.dxftype() == "POINT":
print(e.dxf.get_default("location"))
doc.entitydb.delete_entity(e)
doc.saveas("no_points_.dxf")