- From: "Daniel B. Thurman" <dant cdkkt com>
- To: GTK Applications <gtk-app-devel-list gnome org>
- Subject: os.listdir() exceptions
- Date: Sat, 24 Oct 2009 08:30:09 -0700
Is os.listdir(path) the only method available for obtaining
directory/file list for the given path argument?
The reason I am asking is this: what if one wishes to obtain
a listing of, say the root directory (/), and in the case of using
the linux os, for example, one may encounter a directory
called: /.dbus, which is owned by root and not accessible
to a normal user, and may cause os.listdir() to throw an
OS.Error (permission denied) exception and to subsequently
terminate the os.listdir() method.
How does one get around this exception, to allow os.listdir()
to continue and to ignore these exceptions, whatever they
are, so that these exceptions can be handled with further
code as desired by the programmer?
I am tempted to use a pipe with /usr/bin/ls to get around
os.listdir(path), but this could break portability with other
Does anyone have an idea or a solution?
] [Thread Prev