On Thu, Sep 23, 2021 at 4:20 AM Dennis Lee Bieber wrote:
>
> The other alternative may be
> https://docs.python.org/3/library/functions.html#__import__
>
I wouldn't recommend calling a dunder. If you just want to pass a text
string and get back a module, importlib is a better choice.
Chr
On Tue, 21 Sep 2021 18:58:31 +, Travis Griggs
declaimed the following:
>from lib import paths
>import paths.dynamic_client_module()
>
>But this seems to not work. Import can only take real modules? Not programatic
>ones?
Consider "import" to be equivalent to a compile-time operatio
On Wed, Sep 22, 2021 at 6:05 AM <2qdxy4rzwzuui...@potatochowder.com> wrote:
>
> On 2021-09-22 at 05:10:02 +1000,
> Chris Angelico wrote:
>
> > You can dynamically import modules using importlib.import_module(),
> > but an easier way might just be a conditional import:
> >
> > # client/__init__.py
On 2021-09-22 at 05:10:02 +1000,
Chris Angelico wrote:
> You can dynamically import modules using importlib.import_module(),
> but an easier way might just be a conditional import:
>
> # client/__init__.py
> if some_condition:
> import module_a_default as module_a
> else:
> import module
On Wed, Sep 22, 2021 at 4:59 AM Travis Griggs wrote:
>
> I guess this is kind of like mocking for testing. I have a simple module
> that's imported in a number of other spots in my program. There's a condition
> in the OS/filesystem where I'd like to import a polymorphically compatible
> varian
I guess this is kind of like mocking for testing. I have a simple module that's
imported in a number of other spots in my program. There's a condition in the
OS/filesystem where I'd like to import a polymorphically compatible variant of
the same module. Can this be accomplished in a sort of once