Packages, modules and exceptions
Steve Purcell
stephen_purcell at yahoo.com
Mon Mar 12 10:39:07 EST 2001
Ng Pheng Siong wrote:
>
> In M2Crypto, I have the following (abridged) directory structure:
>
> M2Crypto/
> SSL/
> __init__.py
> Connection.py
>
I assume you also have a file 'M2Crypto/__init__.py'...
> Now, various parts of M2Crypto/SSL/Connection.py wish to raise SSLError
> when it is appropriate to do so.
>
> For M2Crypto/SSL/Connection.py to get access to SSLError which is defined
> in M2Crypto/SSL/__init__.py, it (Connection.py) 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
--
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Any opinions expressed herein are my own and not necessarily those of Yahoo
More information about the Python-list
mailing list