Passing arguments by value...

John F. Brainard jfbrain at lancelot.roundtable.dyndns.org
Thu Feb 24 14:58:45 EST 2000


I'm working on a set of HTML Layout classes for CGI programming
in Python and have stumbled upon a small problem...

The sample code below should be self explanitory...

#begin python code
html = body.Body()

font1 = tags.Font(4, "Arial", "#FF0000")
font1.addText(string.strip("""
	Some text would go in here.
"""))

html.addElement(font)

font1.clearText()
font1.addText(string.strip("""
	Some other text here.
"""))

print "<HTML>" + str(html) + "</HTML>"
#end python code

After I create the font1 object and set it's properties, I add it
to the html object. Then, I change the text and add it again to
the html object. What I get as the output is...

#Begin HTML here
<HTML>
<body>
<font size=1 face="Arial" color="#FF0000">
Some other text here.
</font>

<font size=1 face="Arial" color="#FF0000">
Some other text here.
</font>
</HTML>
#End HTML here

Is there a way to copy the font object or pass it by value rather
than reference to the addElement() function?

Thank you,

John F. Brainard Jr.
johnbrainard at stny.rr.com



More information about the Python-list mailing list