...how do I get hold of a list of its subdirectories?

This does what you asked for:

import os
targetpath='c:\\'
all=os.listdir(targetpath)
subdirs=[x for x in all
         if os.path.isdir(os.path.join(targetpath, x))]

But you may need to take a look at os.walk (as others
have suggested) also.

Larry Bates

Sean McIlroy wrote:
And now for a pair of questions that are completely different:

1) I'd like to be able to bind callbacks to presses of the arrow
buttons on the keyboard. How do you say that in Tkinter?

2) The function 'listdir' in os.path returns a list of all the files
in the given directory - how do I get hold of a list of its
subdirectories?

Any help will be greatly appreciated.

Peace,
STM
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to