Class not registered???
Alex Martelli
aleax at aleax.it
Sat Jan 19 06:49:45 EST 2002
maximilianscherr wrote:
> thanks,
>
> how can i make a check if wsh2.0 or newer is installed? so that i can
> show a nice error messagebox:)
Not sure about the version (maybe some object in WSH has a version
property you can check?), but as for it being installed at all:
try: shell = win32com.client.Dispatch("WScript.Shell")
except pythoncom.com_error, error_obj:
show_nice_errormessage(error_obj)
sys.exit(1)
should work. In general, try/except is best in python for such "checks":
try doing what you need, handle the exception if that doesn't work. This
idiom is known as "it's easier to get forgiveness than permission" (IEGFTP)
as opposed to trying to check everything in advance, known as "Look
before you leap" (LBYL).
Alex
More information about the Python-list
mailing list