Oops.... I get an error using that code.. <br><br> if filename.endswith('.cap','.fru','.hex') or filename.endswith('.sdr', '.cfg'):<br>TypeError: slice indices must be integers or None<br><br><div><span class="gmail_quote">
On 10/14/06, <b class="gmail_sendername">Bill Burns</b> <<a href="mailto:billburns@pennswoods.net">billburns@pennswoods.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Chris Hengge wrote:<br>> First question..<br>><br>> This is the code that I have:<br>> for filename in zfile.namelist():<br>> outfile = open(filename, 'w')<br>> outfile.write(zfile.read(filename))
<br>> outfile.close()<br>><br>> Is there a way to say :<br>> for filename in zfile.namelist() contains '.txt, .exe':<br>> outfile = open(filename, 'w')<br>> outfile.write(zfile.read
(filename))<br>> outfile.close()<br><br><br>Maybe take a look at 'endswith':<br><br>Example:<br>for filename in zfile.namelist():<br> if filename.endswith('.exe') or filename.endswith('.txt'):<br> # do something with filename
<br><br><br>> second question is along the same lines..<br>><br>> I'm looking for a way to say:<br>> os.remove('All by .py')<br>><br>> or-<br>><br>> os.remove('*.txt, *.exe')<br>><br>> Thank you all again for your time and effort.
<br>><br>><br>> ------------------------------------------------------------------------<br>><br>> _______________________________________________<br>> Tutor maillist - <a href="mailto:Tutor@python.org">
Tutor@python.org</a><br>> <a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br><br></blockquote></div><br>