Catching user defined exceptions from foreign modules

Dennis Lee Bieber wlfraed at ix.netcom.com
Mon Sep 30 19:55:59 CEST 2002


Derek Basch fed this fish to the penguins on Monday 30 September 2002 
08:59 am:

> to have to import user defined exceptions? I dont
> rememeber having to import any of the built in
> exceptions. So, here is the output of the fixed test1:
>
        "built-in" -> already there... <G>

 
> test2.TestError
> fudge
> 
> Am I doing this all wrong?

        You want to use items defined in an imported module. I see three 
alternatives...

import module

        all uses then become module.item

from module import item1, item2, ... itemN

        only the named items are useable, but can be used as itemM

from module import *

        practically everything within the module is available as item

The last is not recommended as you can encounter unexpected 
redefinition of names... In the last week we had one such...

from os import *

replaces the Python open() (which I understand is being phased out for 
file()) with the low-level (C-style) open -- totally different 
arguments needed.

--
 > ============================================================== <
 >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed at dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



More information about the Python-list mailing list