Problem with filter()
Boudreau, Emile
Emile.Boudreau at cognos.com
Tue Apr 3 11:00:59 EDT 2007
Sorry folks my mistake def is_dev should be:
def is_Dev(stringy):
stringx = stringy.split('-')
if stringx[0] == '':
if stringx[1] == r'win32':
if stringx[2] == r'app':
if stringx[4] == r'dev.tar.gz':
return 1
But now the results of the filter is an empty list and i know it
shouldn't be.
Emile Boudreau
________________________________
From: python-list-bounces+emile.boudreau=cognos.com at python.org
[mailto:python-list-bounces+emile.boudreau=cognos.com at python.org] On
Behalf Of Boudreau, Emile
Sent: Tuesday, April 03, 2007 10:52 AM
To: python-list at python.org
Subject: Problem with filter()
Hey all,
So I'm trying to filter a list with the built-in function
filter(). My list looks something like this:
['logs', 'rqp-8.2.104.0.dep', 'rqp-8.2.93.0.dep',
'rqp-win32-app-8.2.96.0-inst.tar.gz',
'rqp-win32-app-8.2.96.0-inst.tar.gz']
Calling filter like this: compFiles = filter(is_Dev, compFiles)
compFiles is my list and is_dev is the following
def is_Dev(stringy):
print stringy
stringx = stringy.split('-')
if stringx[1] == r'win32':
if stringx[2] == r'app':
if stringx[4] == r'dev.tar.gz':
return 1
For some reason I only get 'logs' printed when is_Dev is called. (ie.
It's only going through is_dev once)
Does anyone see something wrong that I'm not seeing??
Thanks,
Emile Boudreau
This message may contain privileged and/or confidential
information. If you have received this e-mail in error or are not the
intended recipient, you may not use, copy, disseminate or distribute it;
do not open any attachments, delete it immediately from your system and
notify the sender promptly by e-mail that you have done so. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070403/8cd81c97/attachment.html>
More information about the Python-list
mailing list