Move modules to submodules question

J

joshua.kimball

I have a set of utility modules that were all added to a folder called (util_mods). Recently the set of modules grew to be too large and I've been working on splitting it up into sets of sub modules, for example, util_mods\set_a. The issue is that if I start moving modules to sub folders I have to go through and update literally thousands of scripts that import the module from util_mods. I was wondering if there was a way to move these modules into submodules while still maintaining the imports. For example "import util_mods.moda " would actually import as "util_mods.set_a.moda".

My longterm goal is to update the scripts to point to the correct submodule/module however I was hoping for a short term solution to this so I can make the change immediately and update the other scripts over time.
 
P

Peter Otten

I have a set of utility modules that were all added to a folder called
(util_mods). Recently the set of modules grew to be too large and I've
been working on splitting it up into sets of sub modules, for example,
util_mods\set_a. The issue is that if I start moving modules to sub
folders I have to go through and update literally thousands of scripts
that import the module from util_mods. I was wondering if there was a way
to move these modules into submodules while still maintaining the imports.
For example "import util_mods.moda " would actually import as
"util_mods.set_a.moda".

My longterm goal is to update the scripts to point to the correct
submodule/module however I was hoping for a short term solution to this so
I can make the change immediately and update the other scripts over time.

Put

from .set_a import moda

into util_mods/__init__.py

Alternatively create an additional

util_mods/moda.py

containing nothing but

from .set_a.moda import *
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top