On Sun, 13 Mar 2022 21:55:36 +0100, Les <nagy...@gmail.com> declaimed the following:
>It is hard to explain as it is, but something even more interesting happens >if you try to make them totally independent, and create a copy of the story >as well: > >import copy >doc = SimpleDocTemplate("phello.pdf") >doc.build(copy.copy(Story), onFirstPage=myFirstPage, onLaterPages=myLaterPages) >doc = SimpleDocTemplate("phello2.pdf") >doc.build(copy.copy(Story), onFirstPage=myFirstPage, onLaterPages=myLaterPages) > Note that copy.copy() is a SHALLOW copy (ie; only the top level objects are copied, anything those objects contain are still shared). Try copy.deepcopy() https://docs.python.org/3/library/copy.html """ The difference between shallow and deep copying is only relevant for compound objects (objects that contain other objects, like lists or class instances): A shallow copy constructs a new compound object and then (to the extent possible) inserts references into it to the objects found in the original. A deep copy constructs a new compound object and then, recursively, inserts copies into it of the objects found in the original. """ My hypothesis is that rendering the "story" results in changes to the contained objects (possibly they are even "consumed" as they are rendered -- so you first attempt ends up passing an empty "story" for the second PDF). -- Wulfraed Dennis Lee Bieber AF6VN wlfr...@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ -- https://mail.python.org/mailman/listinfo/python-list