[Tutor] listdir() (original) (raw)
Ole Jensen learning.python at dbmail.dk
Fri Jul 2 08:22:17 EDT 2004
- Previous message: [Tutor] (no subject)
- Next message: [Tutor] listdir()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello list
I have recently learnt of the os.listdir() function, and I intend to experiment with it using a cgi-page (html). I would like to have a base directive show all the files and folders, so that the user can browse through it all. Now, listdir() returns both the files and folders in one big mess, so I am wondering if there is some ListFolderInDir() function or similar within python that I should use, if so what is its name and location.
I realise that if there is no such function it is easy to create one youself using some try: except:statements e.g.
for folder in os.listdir(path): try: print os.listdir(path+folder) except: print folder, "is not a folder!"
and puting that into a function that outputs the what you need.
But for now I was wondering if there is a simpler way to do? like an built in function...
TIA Ole Jensen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tutor/attachments/20040702/c2db737b/attachment.html
- Previous message: [Tutor] (no subject)
- Next message: [Tutor] listdir()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]