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:

stackoverflow: how create namespace bundle in python? built-in back upwards namespace packages in python 3.3 namespace packages in setuptools documentation post namespace packages @ sourceweaver.com

python

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -