Skip to content

Instantly share code, notes, and snippets.

@natesilva
Created December 1, 2009 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natesilva/246511 to your computer and use it in GitHub Desktop.
Save natesilva/246511 to your computer and use it in GitHub Desktop.
# Example showing how Python default argument handling causes a bug
# when using the ReportLab library for Python. Tested against
# ReportLab 2.3.
#
# See http://gist.github.com/246507 for a generic Python example.
from reportlab.platypus import *
def main():
template1 = PageTemplate(id='template1')
template1.frames.append(Frame(0, 0, 10, 20, id='t1_f1'))
template1.frames.append(Frame(30, 40, 50, 60, id='t1_f2'))
template2 = PageTemplate(id='template2')
template2.frames.append(Frame(1, 1, 11, 21, id='t2_f1'))
template2.frames.append(Frame(32, 42, 52, 62, id='t2_f2'))
# I expect to see two frames, but there are actually four.
# All of the frames from template1 have been copied into
# template2.
print [f.id for f in template2.frames]
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment