I am trying to deep copy a Powerpoint object in Python. When I try to copy the presentation object to a new variable it gives an error. When doing a shallow copy it does not give any errors, so it has something to do with the deep copy.
Expected output
Makes a copy of the presentation object without errors.
from pptx import Presentation
import copy
prs1 = Presentation()
prs1.slide_width = Cm(75)
prs1.slide_height = Cm(45)
slide_layout = prs1.slide_layouts[6]
slide = prs1.slides.add_slide(slide_layout)
shapes = slide.shapes
prs2 = copy.deepcopy(prs)
TypeError: __new__() missing 1 required positional argument: 'xFill'
I know it has been asked before, but I don't get it. What do I have to add as argument? __new__
?
This also gives a error: prs2 = copy.deepcopy(prs, Presentation.__new__)
Also a shallow copy does not work, because when I change something in the copied object the orginal object changes aswell.