Detecting OS and Window Manager

Daniel Fackrell dfackrell at
Fri Jun 7 10:14:13 EDT 2002

> Well, in that case we just choose a default.  The thing is, we want to
> detect if PyKDE is installed.  If it is, then we can do "import kdecore"
> without risk of it throwing an exception.  If it isn't, I'd rather not
> have to try something along the lines of attempting "import kdecore" and
> then having to catch an exception if it's not found.

Correct me if I'm wrong, but isn't this exactly the pythonic way of handling
dynamic loading of modules?

    import kdecore
except ImportError:
    # do something else

Of course, this will probably not do what you want in this case, as kdecore
will probably load if it is installed, without regard to whether the current
user is running KDE.  I don't have much experience with this particular
topic yet.

Daniel Fackrell

More information about the Python-list mailing list