Another newbie question

Roman Suzi rnd at onego.ru
Sun May 26 23:35:19 EDT 2002


On Sun, 26 May 2002, SA wrote:

>I am trying to find a way to list the contents of a directory into a list so
>that the contents of the list are then read into an html doc as hrefs.

import os
lst = os.listdir("/path/to/dir")

or

import glob
lst = glob.glob("path/to/dir/*") 



>What I'm looking for is a way to ls a directory. Is there a way to access
>the shell command ls from within a python script and dumping the output into
>a list for further manipulation? Or does this have to be built from the
>ground up inside the python script?
>
>Thanks.
>SA
>
>

Sincerely yours, Roman Suzi
-- 
\_ Russia \_ Karelia \_ Petrozavodsk \_ rnd at onego.ru \_
\_ Monday, May 27, 2002 \_ Powered by Linux RedHat 7.2 \_
\_ "Politics is the entertainment branch of industry." \_






More information about the Python-list mailing list