help understanding class or function

Vincent Davis vincent at vincentdavis.net
Thu Mar 5 11:43:12 EST 2009


If I have a list and I what to make changes to it.a = [1,2,3,4,5,6,7,8,9]
and maybe I want to drop the odd and double the  even numbers and I will
need to do this repeatedly.
How is this best done? That is as a function or class. All I know how to do
is

def doubleeven(alist):
    blist = [2*x for x in a if x % 2 ==0]
   return blist

then when I am using it I do this

a = doubleeven(a)
I what to keep it named "a"

I am not sure if this is the best way in terms of format or structure. Is
there a better way.

Thanks
Vincent Davis
720-301-3003
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090305/ed7f28a9/attachment.html>


More information about the Python-list mailing list