Bart Van Loon wrote:
> Hi all,
> 
.......
> 
> #--------------------------------------------------
> 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?
.......

would it not be simpler to just use

        ..... alist+[num].....

where you need it? Seems more natural than

def addnumber(alist,num):
        return alist+[num]

and then

        ......addnumber(alist,num)......

-- 
Robin Becker

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to