Message249272
It sounds like you are trying to do a plain “import email”, and then expect all the submodules under that package to work, including “email.mime.nonmultipart”. That is not how it works. I understand the submodules and subpackages are only initialized if you ask for them explicitly. Hence the “no attribute 'mime' ” error in 3.4.
In your case perhaps you should change or extend the import statement to do
import email.mime.nonmultipart
The reason why your “from . . . import” works is it also initializes the submodule that you want, and stores it in a chain of attributes of the top-level module as a side effect.
Quickly scanning through <https://docs.python.org/3/tutorial/modules.html#packages>, <https://docs.python.org/3/reference/import.html#packages>, <https://docs.python.org/3/reference/simple_stmts.html#import>, I didn’t see anything obvious pointing out that importing a top-level package doesn’t completely initialize the whole thing. But maybe there is something already there. You might have to read about how the __init__.py internals work to pick it up. |
|
Date |
User |
Action |
Args |
2015-08-28 03:11:48 | martin.panter | set | recipients:
+ martin.panter, r.david.murray, SegundoBob |
2015-08-28 03:11:48 | martin.panter | set | messageid: <1440731508.19.0.853199071869.issue24949@psf.upfronthosting.co.za> |
2015-08-28 03:11:48 | martin.panter | link | issue24949 messages |
2015-08-28 03:11:46 | martin.panter | create | |
|