473,287 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Library package import question

Hello,

I have a python library package 'Foo', which contains alot of submodules:

Foo/:
__init__.py
module1.py:
class Bar()
class Hmm()
module2.py
class Bee()
class Wax()
module3.py
etc etc

To prevent namespace pollution, I want to import and use this library in the
following way:

import Foo
(...)
t = Foo.module2.Bee()

To accomplish this, I put explicit imports in __init__.py:

import module1
import module2
import module3

what Im wondering about, is if its a more refined way of doing this, as the
explicit imports now need to be manually maintained if the library grows.
I've tried to use __all__, but this only seems to work with "from Foo import
*" and it causes modules to be imported directly into the namespace of
course.

Thanks for input.
-Frank
Nov 5 '07 #1
0 804

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David M. Wilson | last post by:
Hello! I maintain a small package for talking to the API of BulkSMS.co.uk. I have been adding support for some new features recently, and found myself slightly indecisive over how best to lay...
0
by: C. Barnes | last post by:
OK, here's the setup: package/ __init__.py X.py python/lib/ X.py Now inside package, we want to import the copy
7
by: Kevin Newman | last post by:
I've been toying with a namespace manager, and wanted to get some input. So what do you think? if (typeof com == 'undefined') var com = {}; if (!com.unFocus) com.unFocus = {}; ...
0
by: anonymous | last post by:
Hey all, I sent this as a response to someone else's problem, but then I thought it might be useful to more people so I'm starting a new thread to share and discuss it. I found a great JavaScript...
5
by: sophie_newbie | last post by:
OK this might seem like a retarded question, but what is the difference between a library and a module? If I do: import string am I importing a module or a library? And if i do...
2
by: sauce | last post by:
Hi, this a newbie question, forgive me! Ok so I have some code written using the libxml2dom package (because I want to parse html pages) and I would like to have this work on a web server. The web...
0
by: Roger Ineichen | last post by:
Hi Tim For a usecase like this, I personaly recommend to defina all interfaces in one module which probably is a namespace if you need alot of interfaces to define. e.g. ...
3
by: MyPetSlug | last post by:
Hello Guys, Using Pythong 2.4 and py2exe 0.6.6. So, I've created a wxPython application that I use for testing. The idea is to have a tests directory so that every time the application starts, it...
1
by: mypetslug | last post by:
Hi, I'm sorry if this has been asked before, but I can't seem to find an answer to this anywhere and so far, trial and error hasn't gotten me far either. Using python 2.4, I've created a...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.