Bart> #-------------------------------------------------- Bart> def addnumber(alist, num): Bart> """ work around the inplace-ness of .append """ Bart> mylist = alist[:] Bart> mylist.append(num) Bart> return mylist Bart> #--------------------------------------------------
Bart> and I am wondering if this is good practice or not. Bart> any advice on this matter? Such an operation will be O(N**2), and thus expensive if performed frequently on lists of moderate length. I've never been tempted to do this. Can you say a little about why you'd want to do this? Knowing that, perhaps someone here can point you in a more Pythonic direction. Skip -- http://mail.python.org/mailman/listinfo/python-list