Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31166
| Date | 2012-10-12 12:28 -0400 |
|---|---|
| From | Dave Angel <d@davea.name> |
| Subject | Re: Checking for dlls in ctypes |
| References | <975da919-c70a-492a-9d49-62254a76eb6c@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2092.1350059331.27098.python-list@python.org> (permalink) |
On 10/12/2012 11:36 AM, Wanderer wrote: > I'm trying to write some code that will load one of three dll depending on the one available. I've tried the code below, but it doesn't work. The try except doesn't catch the exception. Is there a way to do this? > > try: > self.dll = windll.pvcam64 > except: > print "No pvcam64" > try: > self.dll = windll.pvcam32 > except: > print "No pvcam32" > try: > self.dll = windll.pvcam > except: > print "No pvcam" > return > else: > print "installed pvcam" > else: > print "installed pvcam32" > else: > print "installed pvcam64" > I can't help you find the dll's, because I don't run Windows. But I could help you write a clearer question: "doesn't work" is thoroughly useless for describing errors. If you're getting an exception, show us the full traceback. That will show which statement got the exception that wasn't caught. Next question is which of the dlls is missing. Are you getting an exception because it's missing or because of something more fundamental, like nesting exception handlers? Using bare excepts is almost never a good idea. If it "works" you get no clues what went wrong. For example, a typo in source code can trigger a bare exception, as can a user typing Ctrl-C. So when you're using bare excepts, you have robbed the user of any way to terminate the program. If I were you, I'd be writing a loop so there's only one try block. Too much duplicated code in the way you're doing it. -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Checking for dlls in ctypes Wanderer <wanderer@dialup4less.com> - 2012-10-12 08:36 -0700
Re: Checking for dlls in ctypes Dave Angel <d@davea.name> - 2012-10-12 12:28 -0400
Re: Checking for dlls in ctypes Wanderer <wanderer@dialup4less.com> - 2012-10-12 10:57 -0700
Re: Checking for dlls in ctypes Wanderer <wanderer@dialup4less.com> - 2012-10-12 10:57 -0700
Re: Checking for dlls in ctypes Nobody <nobody@nowhere.com> - 2012-10-13 12:32 +0100
Re: Checking for dlls in ctypes MRAB <python@mrabarnett.plus.com> - 2012-10-12 17:57 +0100
Re: Checking for dlls in ctypes Wanderer <wanderer@dialup4less.com> - 2012-10-12 10:52 -0700
Re: Checking for dlls in ctypes Wanderer <wanderer@dialup4less.com> - 2012-10-12 10:52 -0700
Re: Checking for dlls in ctypes 88888 Dihedral <dihedral88888@googlemail.com> - 2012-10-13 06:40 -0700
csiph-web