Import trouble

Craig Ringer craig at postnewspapers.com.au
Wed Dec 15 08:52:19 EST 2004


On Wed, 2004-12-15 at 21:44, Craig Ringer wrote:

> def import_xml:
>    try:   
>        import libxml
>    except ImportError,err:
>        # handle the error
>    return libxml
> 
> libxml = import_xml()

Though my personal approach would actually be:

try:
    import libxml
except ImportError,err:
   handle_import_error("libxml", err)

--
Craig Ringer




More information about the Python-list mailing list