suppressing import errors

Andreea Babiuc babiucandreea at gmail.com
Tue Nov 15 12:35:09 EST 2011


On 15 November 2011 17:24, Chris Kaynor <ckaynor at zindagigames.com> wrote:

> 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.
>
>
Hmm, I know this might sound silly, but if it fails I still want to import
the module and disable those lines of code that are related to the reason
while the module failed to be imported in the first place.  Even if that
makes the code not 100% correct.

Does that make sense ?









> 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 <babiucandreea at gmail.com>
> 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
> >
> >
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Blog: Http://andreeababiuc.ro
Photo Portfolio: http://royaa.daportfolio.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111115/729eae74/attachment-0001.html>


More information about the Python-list mailing list