Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'imports': 0.07; 'suppress': 0.07; 'python': 0.08; '(rather': 0.09; 'block.': 0.09; 'exceptions': 0.09; 'am,': 0.12; 'exception': 0.12; 'except:': 0.16; 'subject:import': 0.16; 'wrote:': 0.18; 'python?': 0.18; 'wrap': 0.18; 'possibly': 0.21; 'trying': 0.21; 'header:In-Reply- To:1': 0.23; 'received:74.125.82.174': 0.24; 'received:mail- wy0-f174.google.com': 0.24; 'thanks.': 0.26; "i'm": 0.26; 'code,': 0.27; 'url:mailman': 0.27; 'import': 0.28; 'pass': 0.28; 'importing': 0.28; 'module.': 0.28; 'message-id:@mail.gmail.com': 0.29; 'module': 0.30; 'imported': 0.30; 'chris': 0.30; 'nov': 0.31; 'hi,': 0.31; 'tue,': 0.32; 'url:listinfo': 0.32; 'to:addr :python-list': 0.32; 'there': 0.33; 'statement,': 0.34; 'try:': 0.34; 'url:python': 0.35; 'received:74.125.82': 0.37; 'received:google.com': 0.38; 'url:org': 0.38; 'received:74.125': 0.39; 'except': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; '2011': 0.62; 'alternative': 0.63 MIME-Version: 1.0 In-Reply-To: References: From: Chris Kaynor Date: Tue, 15 Nov 2011 09:24:03 -0800 Subject: Re: suppressing import errors To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1321377867 news.xs4all.nl 6981 [2001:888:2000:d::a6]:50461 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15724 As with any Python code, you can wrap the import into a try: except block. try: import badModule except: pass # Or otherwise handle the exception - possibly importing an alternative module. As with any except statement, specific exceptions may be caught (rather than the blank, catch everything). Chris On Tue, Nov 15, 2011 at 9:11 AM, Andreea Babiuc wrote: > Hi, > > Is there a way to suppress all the errors when importing a module in python? > > By that I mean.. If I have other imports in the module I'm trying to import > that fail, I still want my module to be imported that way.. > > Many thanks. > > -- > http://mail.python.org/mailman/listinfo/python-list > >