Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #13276 > unrolled thread
| Started by | Jack Bates <jack.bates@gmail.com> |
|---|---|
| First post | 2011-09-14 09:22 -0700 |
| Last post | 2011-09-14 09:22 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: ImportError: cannot import name dns Jack Bates <jack.bates@gmail.com> - 2011-09-14 09:22 -0700
| From | Jack Bates <jack.bates@gmail.com> |
|---|---|
| Date | 2011-09-14 09:22 -0700 |
| Subject | Re: ImportError: cannot import name dns |
| Message-ID | <mailman.1121.1316017681.27778.python-list@python.org> |
> It is a circular dependency. Dns will try to import udp which will in turn import dns (again) in an endless cycle; instead an ImportError is raised. > > Circular dependency is a Bad Thing. According to this documentation: http://docs.python.org/reference/simple_stmts.html#grammar-token-import_stmt http://effbot.org/zone/import-confusion.htm - I thought Python would do something like: 1. check for "dns" in sys.modules (initially not found) 2. create new empty module, add it to sys.modules as "dns" 3. execute dns.py in new module namespace (executes "from foo import udp") 4. check for "udp" in sys.modules (not found) 5. create new empty module, add it to sys.modules as "udp" 6. execute udp.py in new module namespace (executes "from foo import dns") 7. check for "dns" in sys.modules (found!) 8. done executing udp.py 9. done executing dns.py So I'd expect attempting to access symbols from "dns" while executing udp.py to fail, because dns.py isn't done executing at this point. However I don't attempt to access any symbols from "dns" - so I don't expect this ImportError What is my mistake?
Back to top | Article view | comp.lang.python
csiph-web