Message84993
| Author |
ncoghlan |
| Recipients |
brett.cannon, bronger, dcjim, gvanrossum, jhylton, loewis, ncoghlan, tim.peters |
| Date |
2009年04月01日.10:38:24 |
| SpamBayes Score |
1.7904634e-07 |
| Marked as misclassified |
No |
| Message-id |
<1238582305.71.0.0294301476281.issue992389@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|