Renaming an import
Cameron Simpson
cs at cskk.id.au
Thu Sep 5 23:19:27 EDT 2019
On 05Sep2019 20:31, Michael Speer <knomenet at gmail.com> wrote:
>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?
Or without a stub file and only slightly less conveniently:
pkg/__init__.py
import graphing_module_b as graph
pkg/foobar.py
from . import graph
plot = graph.plot
axis = graph.axis
Alternatively:
pkg/__init__.py
import graphing_module_b as graph
plot = graph.plot
axis = graph.axis
pkg/foobar.py
from . import graph, plot, axis
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Python-list
mailing list