Nick Coghlan <ncogh...@gmail.com> added the comment: No argument from me that my suggestion is a mere glimmering of an idea, rather than a fully worked out definitely viable solution.
It was just an angle of attack I hadn't seen suggested before, so I figured it was worth mentioning - the fact that a module is allowed to exist in sys.modules while only half constructed is the reason "import a.b.c" can work while "from a.b import c" or an explicit relative import will fail - the first approach gets a hit in sys.modules and succeeds, while the latter two approaches fail because the a.b package doesn't have a 'c' attribute yet. Figuring out a way to set the attribute in the parent package and then roll it back later if the import fails is still likely to be the more robust approach. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue992389> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com