Skip to main content

Nested Imports for Python

Project description

Allows nested imports, a la Java. It installs a harmless meta import-hook that adds support for nested packages, i.e., multiple packages that “live” under a common namespace. This is the idiom in Java, where you have packages like com.foo.bar.spam and com.foo.bar.eggs, as well as in Haskell. Nimp basically allows packages to “inject” themselves into shared namespaces.

Compatible with Python 2.3 and up and 3.0 and up

Usage:

import nimp
nimp.install()

Example Layout

Assume the following directory structure, say, in your site-packages:

com.ibm.storage/
  files...
com.ibm.storage.plugins/
  files...
com.ibm.pythontools/
  files...

Using Nimp, the following imports will work as expected:

import com                              # a namespace package (empty)
import com.ibm                          # a namespace package (empty)
import com.ibm.pythontools              # a real package
com.ibm.pythontools.myfunc(1,2,3)

# and of course using `from` works too
from com.ibm.storage import ScsiDisk

# note how the `plugins` package was "injected" into `storage`
from com.ibm.storage.plugins import MySQLPlugin

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nimp-0.9.1.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

nimp-0.9.1.win32.exe (200.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page