Split string

Fredrik Lundh effbot at telia.com
Thu Feb 10 18:31:47 CET 2000


Pedro Silva <psilva at ruido-visual.pt> wrote:
> I wnat to split a string that has be return by the filesystem
>
> The code that I'm using is:
>
>         def obj_fs(self):
>             import os
>             listing=os.listdir("/var/spool/news/articles")
>             str=string.split(listing)
>             return str
>
> Is this correct?

why not run the script, and find out
for yourself?

(hints: os.listdir returns a list of filenames.  string.split
takes a string as argument, and returns a list of substrings;
by default, it splits on whitespace).

maybe you should work through the tutorial before trying
to write real stuff in Python?

http://www.python.org/doc/current/tut/tut.html

</F>






More information about the Python-list mailing list