Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #109677 > unrolled thread

Re: [Q] ImportError by __import__() on Python >= 3.4

Started byMichael Selik <michael.selik@gmail.com>
First post2016-06-08 13:24 +0000
Last post2016-06-08 13:24 +0000
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.


Contents

  Re: [Q] ImportError by __import__() on Python >= 3.4 Michael Selik <michael.selik@gmail.com> - 2016-06-08 13:24 +0000

#109677 — Re: [Q] ImportError by __import__() on Python >= 3.4

FromMichael Selik <michael.selik@gmail.com>
Date2016-06-08 13:24 +0000
SubjectRe: [Q] ImportError by __import__() on Python >= 3.4
Message-ID<mailman.78.1465392287.2306.python-list@python.org>
By the way, why choose to write, import, and delete modules? I'd think
exec'ing code would be sufficient.

On Wed, Jun 8, 2016, 5:52 AM Makoto Kuwata <kwa@kuwata-lab.com> wrote:

> On Tue, Jun 7, 2016 at 7:28 AM, Michael Selik <michael.selik@gmail.com>
> wrote:
>
>> On Thu, Jun 2, 2016 at 10:06 AM Makoto Kuwata <kwa@kuwata-lab.com> wrote:
>>
>>> I have a trouble around __import__().
>>>
>>
>> The docs for __import__ strongly recommend that you use importlib instead
>> https://docs.python.org/3.5/library/importlib.html#importlib.import_module
>>
>> The docs for ``importlib.import_module`` suggest that you use
>> ``invalidate_caches`` if you are importing dynamically generated files.
>>
>> https://docs.python.org/3.5/library/importlib.html#importlib.invalidate_caches
>>
>> I think you'll find this fixes your bug.
>>
>
> Great!
> I replaced '__import__()' in my code  with 'importlib.invalidate_cache();
> importlib.import_module()'
> and found it worked very well.
> Thank you very much.
>
> --
> regards,
> makoto
>
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web