Title: RE: two questions - no common theme
[EMAIL PROTECTED]
#- Any help will be greatly appreciated.
It's always better to address two different questions in two different mails, with appropiate subjects.
. Facundo
Bitácora De Vuelo: http://www.taniquetil.com.ar/plog
PyAr - P
2) os.listdir "returns a list containing the names of the entries in the
directory", this does include directories in the top level directory.
For the complete listing try os.walk() which "returns a tuple-(dirpath,
dirnames, filenames"
-Original Message-
From: Sean McIlroy [mailto:[EMAIL
...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.
Larr
Sean McIlroy wrote:
> 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?
, , ,
http://effbot.org/books/tkinterbook/events-and-bindings.htm
For an ordinary 102-key PC-style keyboard, the special keys are Cancel
(th
def walktree(self,top=".", depthfirst=False):
"""
Walk a directory tree, starting from 'top'
This code is based on os.path.walk, with the callback function
replaced by a yield and recursion replaced by iteration
"""
if type(top) != types.StringType:
os.walk gives an object with all files in a tree, e.g.
f = os.walk('c:\\temp')
for i in f:
print i
--
http://mail.python.org/mailman/listinfo/python-list