Re: Renaming an import

2019-09-05 Thread Peter Otten
Rob Gaddi 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 If you want to go low-level: sys.modules["pkg.graph"] = graph will make > pkg/foobar.py: > from .graph

Re: Renaming an import

2019-09-05 Thread dieter
Rob Gaddi writes: > 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 f

Re: Renaming an import

2019-09-05 Thread Cameron Simpson
On 05Sep2019 20:31, Michael Speer 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 g

Re: Renaming an import

2019-09-05 Thread Michael Speer
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 wrote: > I'm trying to figure out how to rename an import globally for an entire > packa