Oops.... I get an error using that code.. <br><br>&nbsp;&nbsp;&nbsp; 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> &lt;<a href="mailto:billburns@pennswoods.net">billburns@pennswoods.net</a>&gt; 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>&gt; First question..<br>&gt;<br>&gt; This is the code that I have:<br>&gt; for filename in zfile.namelist():<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outfile = open(filename, 'w')<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outfile.write(zfile.read(filename))
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outfile.close()<br>&gt;<br>&gt; Is there a way to say :<br>&gt; for filename in zfile.namelist() contains '.txt, .exe':<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outfile = open(filename, 'w')<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outfile.write(zfile.read
(filename))<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outfile.close()<br><br><br>Maybe take a look at 'endswith':<br><br>Example:<br>for filename in zfile.namelist():<br>&nbsp;&nbsp;&nbsp;&nbsp; if filename.endswith('.exe') or filename.endswith('.txt'):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # do something with filename
<br><br><br>&gt; second question is along the same lines..<br>&gt;<br>&gt; I'm looking for a way to say:<br>&gt; os.remove('All by .py')<br>&gt;<br>&gt; or-<br>&gt;<br>&gt; os.remove('*.txt, *.exe')<br>&gt;<br>&gt; Thank you all again for your time and effort.
<br>&gt;<br>&gt;<br>&gt; ------------------------------------------------------------------------<br>&gt;<br>&gt; _______________________________________________<br>&gt; Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;<a href="mailto:Tutor@python.org">
Tutor@python.org</a><br>&gt; <a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br><br></blockquote></div><br>