Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36639 > unrolled thread

Move modules to submodules question

Started byjoshua.kimball@gmail.com
First post2013-01-11 11:30 -0800
Last post2013-01-11 21:33 +0100
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Move modules to submodules question joshua.kimball@gmail.com - 2013-01-11 11:30 -0800
    Re: Move modules to submodules question Peter Otten <__peter__@web.de> - 2013-01-11 21:33 +0100

#36639 — Move modules to submodules question

Fromjoshua.kimball@gmail.com
Date2013-01-11 11:30 -0800
SubjectMove modules to submodules question
Message-ID<697510fc-4048-47fc-9104-41b845283011@googlegroups.com>
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.

[toc] | [next] | [standalone]


#36643

FromPeter Otten <__peter__@web.de>
Date2013-01-11 21:33 +0100
Message-ID<mailman.413.1357936445.2939.python-list@python.org>
In reply to#36639
joshua.kimball@gmail.com 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 *

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web