[Tutor] lists and s.split

Not Important oplin_eater@yahoo.com
Fri Mar 21 06:39:01 2003


--0-145160292-1048189418=:16055
Content-Type: text/plain; charset=us-ascii


i am trying to create a script that will make dirs for a part of a selected file name using string.split but can only make it work for one file name not many 

import os
import string

os.chdir("dir")

list = os.listdirs("dir")

for name in list
    dir_name string.split(name " - ")[1]

i can only get dir_name to represent on of the file names in directory but i would like it to be a list of all the names 

how if possible. 



---------------------------------
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
--0-145160292-1048189418=:16055
Content-Type: text/html; charset=us-ascii

<P>i am trying to create a script that will make dirs for a part of a selected file name using string.split but can only make it work for one file name not many </P>
<P>import os<BR>import string</P>
<P>os.chdir("dir")</P>
<P>list = os.listdirs("dir")</P>
<P>for name in list<BR>&nbsp;&nbsp;&nbsp; dir_name string.split(name " - ")[1]</P>
<P>i can only get dir_name to represent on of the file&nbsp;names in directory&nbsp;but i would like it to be a list of&nbsp;all the names </P>
<P>how if possible.&nbsp;</P><p><br><hr size=1>Do you Yahoo!?<br>
<a href="http://rd.yahoo.com/platinum/evt=8162/*http://platinum.yahoo.com/splash.html">Yahoo! Platinum</a> - Watch CBS' NCAA March Madness, <a href="http://rd.yahoo.com/platinum/evt=8162/*http://platinum.yahoo.com/splash.html">live on your desktop</a>!
--0-145160292-1048189418=:16055--