Re-opening a package in Python -
Re-opening a package in Python -
maybe it's not possible (i'm more used ruby, sort of thing fine). i'm writing library provides additional functionality docker-py, provides docker package, import docker , access docker.client etc.
because seemed logical naming scheme, wanted users pull in project import docker.mymodule, i've created directory called docker __init__.py, , mymodule.py within it.
when seek access docker.client, python can't see it, if docker bundle has hidden it:
import docker import docker.mymodule docker.client() # attributeerror: 'module' object has no attribute 'client' is possible, or top-level bundle names have differ between source trees?
this possible if docker set namespace package (which it isn't).
see zope.schema, zope.interface, etc. illustration of namespace bundle (zope namespace bundle here). because zope declared namespace bundle in setup.py, means zope doesn't refer particular module or directory on file system, namespace shared several packages. means result of import zope pretty much undefined - import top-level module of first zope.* bundle found in import path.
therefore, when dealing namespace packages, need explicitely import specific 1 import zope.schema or from zope import schema.
unfortunately, namespace packages aren't documented. noted @bakuriu in comment, these resources contain helpful information:
python
Comments
Post a Comment