Hi all,

I would like to find out of a good way to append an element to a list
without chaing that list in place, like the builtin list.append() does.

currently, I am using the following (for a list of integers, but it
could be anything, really)

#--------------------------------------------------
def addnumber(alist, num):
    """ work around the inplace-ness of .append """ 
    mylist = alist[:]
    mylist.append(num)
    return mylist
#--------------------------------------------------

and I am wondering if this is good practice or not.

any advice on this matter?

thanks!

-- 
regards,
BBBart

   "Someday I'll write my own philosophy book." -Calvin
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to