Packages, modules and exceptions

Steve Purcell stephen_purcell at
Mon Mar 12 16:39:07 CET 2001

Ng Pheng Siong wrote:
> In M2Crypto, I have the following (abridged) directory structure:
>     M2Crypto/
>             SSL/

I assume you also have a file 'M2Crypto/'...

> Now, various parts of M2Crypto/SSL/ wish to raise SSLError 
> when it is appropriate to do so. 
> For M2Crypto/SSL/ to get access to SSLError which is defined
> in M2Crypto/SSL/, it ( contains the following:
>     SSLError = 
>      __import__('M2Crypto.SSL', globals(), locals(), 'SSLError').SSLError
> This works, but looks kinda funny.
> What's the best way to do this?

from M2Crypto.SSL import SSLError
raise SSLError, "there's a problem"


Steve Purcell, Pythangelist
Get testing at
Any opinions expressed herein are my own and not necessarily those of Yahoo

More information about the Python-list mailing list