Packages, modules and exceptions
Ng Pheng Siong
ngps at post1.com
Wed Mar 14 10:58:42 EST 2001
On Mon, Mar 12, 2001 at 04:39:07PM +0100, Steve Purcell wrote:
> I assume you also have a file 'M2Crypto/__init__.py'...
Um, yes; missed that out.
> > 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
>
> from M2Crypto.SSL import SSLError
> raise SSLError, "there's a problem"
Ahh, I wasn't clear enough.
Within M2Crypto/SSL/Connection.py, I have "class Connection:..." Then,
within M2Crypto/SSL/__init__.py, I have "from Connection import
Connection". This is so that clients can say "s = M2Crypto.SSL.Connection()"
instead of "s = M2Crypto.SSL.Connection.Connection()".
Because of this, I can't just do "from M2Crypto.SSL import SSLError"
within Connection.py. __init__.py's "from Connection import Connection"
creates a circular reference.
What's a nice way to fix this fine mess? ;-)
Thanks. Cheers.
--
Ng Pheng Siong <ngps at post1.com> * http://www.post1.com/home/ngps
More information about the Python-list
mailing list