Testing the availability of a module
Fredrik Lundh
fredrik at pythonware.com
Mon Dec 19 10:48:43 EST 2005
Bo Peng wrote:
> > And if you aren't doing the above multiple times, then you *really*
> > shouldn't be worried about the time to load "aModule"
>
> This is used in a scenario like:
>
> if wxPython is available:
> prepare wx based GUI
> elif Tkinter is available:
> prepare tk based GUI
> else:
> command line only
>
> Since a user may prefer command line so wxPython/tkinter should not be
> actually loaded before the GUI function is called.
if the user happens to prefer the command line interface, why bother looking
for a GUI ? sounds like you haven't really thought this through...
here's an outline that matches your use case:
if user wants command line:
command line only
else:
if wxPython is available:
prepare wx based GUI
elif Tkinter is available:
prepare tk based GUI
else:
command line only
</F>
More information about the Python-list
mailing list