git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Renaming an import


pkg/graph.py:
     from graphing_module_b import plot, axis

pkg/foobar.py:
     from .graph import plot, axis

Would it be sufficient to use a file for indirection?


On Thu, Sep 5, 2019 at 7:11 PM Rob Gaddi <rgaddi at highlandtechnology.invalid>
wrote:

> I'm trying to figure out how to rename an import globally for an entire
> package.
>   Something like:
>
> pkg/__init__.py:
>      import graphing_module_b as graph
>
> pkg/foobar.py:
>      from .graph import plot, axis
>
> The point being that, if at some point I decide to change from
> graphing_module_b
> to graphing_module_a, that decision is made at a single central point in
> my
> package rather than scattered through 30 different import statements in a
> dozen
> files.
>
> Any ideas?
>
> --
> Rob Gaddi, Highland Technology -- www.highlandtechnology.com
> Email address domain is currently out of order.  See above to fix.
> --
> https://mail.python.org/mailman/listinfo/python-list
>