Choosable dependency

Dan Stromberg drsalists at gmail.com
Sun Mar 7 23:38:30 EST 2021


I sometimes do things like:

try:
    import rtoml as toml
except ImportError:
    import toml

...but I don't like it very much, because it tends to confuse static
analyzers like pyflakes and pylint.  Maybe mypy will deal with it better?
Not sure yet.

On Sat, Mar 6, 2021 at 3:05 AM Manfred Lotz <ml_news at posteo.de> wrote:

> Let us say I have a package which reads a TOML file.
>
> I want to give the user of my package the choice to decide if he wants
> to use the toml, tomlkit or rtoml package.
>
> So, in case the user chose to use rtoml then there should be an import
> only for rtoml, aso.
>
> How could I achieve this?
>
> --
> Thanks,
> Manfred
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list