Is this correct behavior for default parameters?
Bruce Pearson
BruceP at wn.com.au
Wed Jul 16 00:03:22 EDT 2008
The first call to test has the file_list empty but on the second call to test the file_list is no longer empty but contains the values appended in the first call.
Is this correct behavior? I'm using python 2.5
def test(param_1, file_list = []):
if len(file_list) == 0:
print "Empty list"
file_list.append("list item 1")
file_list.append("list item 2")
else:
raise
if __name__ == "__main__":
test(1)
test(2)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080716/139511ce/attachment.html>
More information about the Python-list
mailing list