Received: by 10.66.80.166 with SMTP id s6mr1955114pax.30.1350127934870; Sat, 13 Oct 2012 04:32:14 -0700 (PDT) Path: jt13ni7901pbb.1!nntp.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!feeder.erje.net!news2.arglkargh.de!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!reader01.nrc01.news.zen.net.uk.POSTED!not-for-mail From: Nobody Subject: Re: Checking for dlls in ctypes Date: Sat, 13 Oct 2012 12:32:14 +0100 User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.python References: <975da919-c70a-492a-9d49-62254a76eb6c@googlegroups.com> MIME-Version: 1.0 Lines: 21 Organization: Zen Internet NNTP-Posting-Host: 86406b6f.news.zen.co.uk X-Trace: DXC=kS3^KUPI4g[:NKnQ:_cV[Sa0UP_O8AJo\=dR0\ckLKGPWeZ<[7LZNRV;^>bE\k^nkXM2Z^cWRFGA[4AEol0emWd] X-Complaints-To: abuse@zen.co.uk X-Received-Bytes: 1899 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Fri, 12 Oct 2012 12:28:17 -0400, Dave Angel wrote: > 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 you want to catch any error, use "except StandardError:". That covers all errors but not things like KeyboardInterrupt (Ctrl-C) or SystemExit (sys.exit()). In situations such as this, where you try multiple candidates until one succeeds, there's no reason to be any more specific than that. In any case, Python's lack of formal interfaces makes it hard to reliably be more specific. However: you should bear in mind that loading the wrong DLL may just result in an OS-level exception (e.g. segfault), which can't be caught. It's preferable to allow the DLL to be explicitly selected e.g. in a configuration file.