Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7766
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'distinct': 0.05; 'imports': 0.07; 'skip:` 10': 0.07; 'python': 0.08; 'url:pypi': 0.08; '-------': 0.09; 'executed': 0.09; 'homepage:': 0.09; 'merging': 0.09; 'namespace': 0.09; 'prefix': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'packages.': 0.14; '"-"': 0.16; 'directories?': 0.16; 'egg': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'naming': 0.16; 'subject:Java': 0.16; 'guess': 0.19; 'header:In-Reply-To:1': 0.21; 'java': 0.21; 'seems': 0.21; 'structure': 0.23; 'appear': 0.23; 'received:84': 0.25; 'stored': 0.25; 'collecting': 0.26; 'example': 0.27; 'e.g.': 0.29; 'import': 0.29; 'convention': 0.29; 'stefan': 0.29; 'work:': 0.29; 'skip:( 20': 0.30; 'calling': 0.31; 'header:X-Complaints- To:1': 0.32; 'does': 0.33; 'to:addr:python-list': 0.33; "isn't": 0.33; 'lines': 0.33; 'rather': 0.34; '...': 0.34; 'install': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; 'skip:" 10': 0.35; 'languages.': 0.35; 'packages,': 0.35; 'using': 0.35; 'two': 0.37; 'url:python': 0.38; 'received:org': 0.38; 'url:org': 0.38; 'but': 0.38; 'though': 0.38; 'subject:: ': 0.38; 'case,': 0.39; 'subject: (': 0.39; 'should': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'allows': 0.40; 'under': 0.40; 'really': 0.40; 'more': 0.60; 'within': 0.60; 'your': 0.60; 'zip': 0.65; 'directories,': 0.84; 'easy:': 0.84; 'hook': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Stefan Behnel <stefan_ml@behnel.de> |
| Subject | Re: Nimp: Nested Imports (a la Java) |
| Date | Thu, 16 Jun 2011 22:17:39 +0200 |
| References | <33dc27c2-cf4a-4915-a546-99834475e636@glegroupsg2000goo.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | dslb-084-056-022-038.pools.arcor-ip.net |
| User-Agent | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10 |
| In-Reply-To | <33dc27c2-cf4a-4915-a546-99834475e636@glegroupsg2000goo.googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.40.1308255473.1164.python-list@python.org> (permalink) |
| Lines | 50 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1308255473 news.xs4all.nl 49042 [::ffff:82.94.164.166]:36839 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:7766 |
Show key headers only | View raw
Tomer Filiba, 16.06.2011 10:48:
> Nimp (Nested Imports) is a little meta-importer hook for Python 2.3-2.7 and 3.0-3.2 that enables the use of *nested packages* (`com.ibm.foo.bar`), as is commonplace in Java and various other languages. It works by collecting all packages that begin with a common prefix on your `sys.path` and "merging" them into logical packages.
>
> Homepage: http://pypi.python.org/pypi/nimp
> Install: pip install nimp
>
> Example
> -------
> Consider the following package layout (say, under site-packages, or anywhere on your python path):
>
> site-packages/
> com-ibm-storage/
> ... package files ...
> com-ibm-storage-plugins/
> ... package files ...
> com-google-protobuf/
> ... package files ...
> com-google-appengine/
> ... package files ...
>
> Using Nimp is easy:
>
> import nimp
> nimp.install()
>
> You can place these two lines in your `site.py`; after calling `nimp.install()`, the following imports will "magically" work:
>
> import com # a namespace package (empty)
> import com.google.protobuf
> import com.ibm.storage
> from com.ibm.storage.plugins import MySQLPlugin
So, this isn't really about "nested imports" but rather about merging
distinct packages, right? This allows me to let packages that are stored in
different places appear within their common package prefix.
Does is really require the "-" naming convention for packages, or would it
also work with normal directories? E.g.
...path1/org/humbug/test/...
...path2/org/humbug/toast/...
That seems like a more common use case: different install directories, egg
directories and zip files that contain the same prefix package directories.
I guess there are issues with "__init__.py" files in this case, though -
which ones should be executed if the package structure is multiplied?
Stefan
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Nimp: Nested Imports (a la Java) Stefan Behnel <stefan_ml@behnel.de> - 2011-06-16 22:17 +0200
csiph-web