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


Groups > comp.lang.python > #36643

Re: Move modules to submodules question

From Peter Otten <__peter__@web.de>
Subject Re: Move modules to submodules question
Date 2013-01-11 21:33 +0100
Organization None
References <697510fc-4048-47fc-9104-41b845283011@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.413.1357936445.2939.python-list@python.org> (permalink)

Show all headers | View raw


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 *

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

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

csiph-web