<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
thanks for the reply - it worked.  I just want to make sure that I
understand the general syntax - when can I use the iteration variable
as x (e..g. print x), and when do I need to use the ...%s... %x syntax?
is it only when I need to call x as a "string"?<br>
<br>
I am not sure I am asking the question right or using the right terms
as I am fairly new to programing and python.<br>
<br>
Thanks for your time.<br>
Ben<br>
<br>
Brian Blais wrote:
<blockquote cite="mid:90B098E8-F2F7-41A9-8B22-A09AB3053696@bryant.edu"
 type="cite">
  <div>
  <div>On Jul 8, 2008, at Jul 8:8:08 PM, Ben Keshet wrote:</div>
  <br class="Apple-interchange-newline">
  <blockquote type="cite">
    <div style="margin: 0px;"><span class="Apple-style-span" style="">I
want to use a 'for' iteration to manipulate files in a set of folders,
something like:</span></div>
    <div style="margin: 0px; min-height: 14px;"><br>
    </div>
    <div style="margin: 0px;">folders= ['1A28','1A6W','56Y7']</div>
    <div style="margin: 0px;">for x in folders:</div>
    <div style="margin: 0px;"><span class="Apple-converted-space">   </span>print
x <span class="Apple-converted-space">    </span># print the current
folder</div>
    <div style="margin: 0px;"><span class="Apple-converted-space">   </span>f
= open('my/path/way/x/my_file.txt', 'r')</div>
    <div style="margin: 0px;"><span class="Apple-converted-space">   </span>...</div>
    <div style="margin: 0px; min-height: 14px;"><br>
    </div>
  </blockquote>
  <div><br>
  </div>
  <div><br>
  </div>
  <div>I think:</div>
  <div><br>
  </div>
  <div>f = open('my/path/way/%s/my_file.txt' % x, 'r')</div>
  <div><br>
  </div>
  <div>should work, although I would probably be more clear about the
names, like:</div>
  <div><br>
  </div>
  <div>folders=['1A28','1A6W','56Y7']</div>
  <div>for folder in folders:</div>
  <div>    filename='my/path/way/%s/my_file.txt' % x</div>
  <div>    fid=open(filename,'r')</div>
  <div>    ....</div>
  <div><br>
  </div>
  <div>also, make sure that you do mean the relative path
 my/path/way/...   # in current folder</div>
  <div>as opposed to the absolute path:  /my/path/way                  
     # in root folder</div>
  <div><br>
  </div>
  <div><br>
  </div>
  <div><span class="Apple-tab-span" style="white-space: pre;"> </span>bb<br>
  </div>
  <div>-- </div>
  </div>
  <div><span class="Apple-style-span"
 style="border-collapse: separate; border-spacing: 0px; color: rgb(0, 0, 0); font-family: Monaco; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px;">
  <div>Brian Blais</div>
  <div><a moz-do-not-send="true" href="mailto:bblais@bryant.edu">bblais@bryant.edu</a></div>
  <div><a moz-do-not-send="true" href="http://web.bryant.edu/%7Ebblais">http://web.bryant.edu/~bblais</a></div>
  <div><br class="khtml-block-placeholder">
  </div>
  <br class="Apple-interchange-newline">
  </span> </div>
  <br>
</blockquote>
</body>
</html>