Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Move modules to submodules question

Reply
Thread Tools

Move modules to submodules question

 
 
joshua.kimball@gmail.com
Guest
Posts: n/a
 
      01-11-2013
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.
 
Reply With Quote
 
 
 
 
Peter Otten
Guest
Posts: n/a
 
      01-11-2013
wrote:

> 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 *

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Noddy with submodules? Torsten Mohr Python 1 09-08-2009 02:57 AM
import X between submodules in a package Donn Ingle Python 7 12-19-2007 05:50 PM
Python submodules and name imports Frank Aune Python 1 08-23-2007 04:48 PM
access to submodules TG Python 10 07-20-2006 07:58 AM



Advertisments