> >>> ipatterns > ('*.txt', '*.hdf', '*.pdf', '*.png') > >>> igf = shutil.ignore_patterns(ipatterns) > >>> ignorethis = igf(ddftopdir,os.listdir(ddftopdir)) > > Traceback (most recent call last): > File "<pyshell#60>", line 1, in <module> > ignorethis = igf(ddftopdir,os.listdir(ddftopdir)) > File "C:\Python27\lib\shutil.py", line 138, in _ignore_patterns > ignored_names.extend(fnmatch.filter(names, pattern)) > File "C:\Python27\lib\fnmatch.py", line 49, in filter > pat=os.path.normcase(pat) > File "C:\Python27\lib\ntpath.py", line 46, in normcase > return s.replace("/", "\\").lower() > AttributeError: 'tuple' object has no attribute 'replace' > > >>> igg = shutil.ignore_patterns('*.txt', '*.hdf', '*.pdf', '*.png') > >>> ignorethat = igg(ddftopdir, os.listdir(ddftopdir)) > >>> ignorethat > set(['Chi2.png', 'DTSdata.hdf', 'TST.hdf', 'BullNoseDiffs.png', > 'DTSall.hdf', 'Symmetry.pdf']) > >>> > ++++++++++++++++++++++++++++ > Why does it fail on passing in a tuple of ignore strings? I thought the , > (comma) is pretty much the tuple constructor (if that is the right word). > > How can I solve this? Is there a way to convert a tuple of strings in a form > that will be accepted? >
Untested, but I think it should work. igf = shutil.ignore_patterns(*ipatterns) Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list