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


Groups > comp.lang.python > #102736

Importing two modules of same name

From Tim Johnson <tim@akwebsoft.com>
Newsgroups comp.lang.python
Subject Importing two modules of same name
Date 2016-02-09 14:23 -0900
Organization AkWebsoft
Message-ID <mailman.1.1455060587.7749.python-list@python.org> (permalink)

Show all headers | View raw


Before proceding, let me state that this is to satisfy my
curiousity, not to solve any problem I am having.

Scenario :
Web application developed at /some/dir/sites/flask/

If I have a package - let us call it app and in my
/some/dir/sites/flask/app/__init__.py is the following:

from config import config

imports the config dictionary from  /some/dir/sites/flask/config.py

(the real-case scenario is M. Grinberg's tutorial on Flask).

What if I wanted to add a module in the app package and call it from
__init__.py

That entails having two modules name config
one at /some/dir/sites/flask/config.py
and the other at /some/dir/sites/flask/app/config.py

What would be the proper way to do this? (If proper at all :)) I
realize that it may not be best practices. And is a practice that I
avoided in the past.

FYI: 
Platform - python 2.7 on Ubuntu 14.04. 
Experience: long-time python CGI programmer before retiring about 3
years ago.

Thanks
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com

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


Thread

Importing two modules of same name Tim Johnson <tim@akwebsoft.com> - 2016-02-09 14:23 -0900

csiph-web