Message140722
| Author |
cool-RR |
| Recipients |
brett.cannon, brian.curtin, cool-RR, eric.araujo, eric.snow, r.david.murray |
| Date |
2011年07月20日.07:29:54 |
| SpamBayes Score |
1.783176e-07 |
| Marked as misclassified |
No |
| Message-id |
<1311146995.44.0.0399538854067.issue12583@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
David, I don't think you've read my message carefully enough. I'm well aware that there are other ways in Python to import than the `import` statement. I'm proposing that it doesn't matter.
I asked, "isn't a circular import when you try to import a module `foo` while in a lower stack level you haven't finished importing `foo` yet?" If this is true, then you just need to have some kind of flag for each module saying "This module is currently being imported", which you set to `True` when you start importing and back to `False` when you finished importing. (It doesn't have to look exactly like this, it could be a context manager, or alternatively a centralized list of all module that are currently in the middle of an import.) Then when you have an `ImportError`, you check whether the module that the user tried to import has that flag raised, and if so notify him that it's probably a circular import problem.
Will that work? |
|