circular import snafu

Mookie D. mookied at iname.com
Fri Aug 11 18:02:23 EDT 2000


In article <8F8C54FBFgmcmhypernetcom at 199.171.54.155>,
  gmcm at hypernet.com (Gordon McMillan) wrote:
> [posted and mailed]
>
> >  File "/usr/local/dm/webapp/subscription.py", line 16, in ?
> >    import email
>
> >  File "email.py", line 18, in ?
> >    import dmpost
>
> >  File "dmpost.py", line 29, in ?
> >ImportError: cannot import name MailList
>
> Don't know how dmpost imports MailList. If it's with "from", that's a
> problem. Another thing you can do is delay some of the imports. If
> "scrobble" if module A is the only place in A that module B is used,
then
> you can use:
>
> def scrobble(...):
>   import B
>   ...
>
> The 2nd and subsequent times that "import" is hit, it won't do
anything,
> (although it won't be free, either).

Gordon: thanks a lot!  This solved things.  It's complicated because
there are multiple possible entry points for the app, depending on use
(sharing code base for two tools).

-Mook


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list