Filter function and lists
John Townsend
jtownsen at adobe.com
Wed Oct 29 15:45:26 EDT 2008
I'm trying to figure out how to use filter to walk through a list.
If I try a simple scripts like this:
def greaterthanten (number):
#pdb.set_trace()
if (number > 10):
ret_val = 1
else:
ret_val = 0
return ret_val
old_list = [1,2,20,30,5]
new_list = filter(greaterthanten, old_list)
#new_list becomes [20, 30]
The script works as I would expect. However, what if I need to pass more than one argument to the function? Can I do that with filter? Or does filter work only with function that take only a single arg?
Thanks
John Townsend (5-7204),
AGM-FL and PSL QE Lead
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081029/495fa511/attachment.html>
More information about the Python-list
mailing list