Maybe it's not possible (I'm more used to Ruby, where this sort of thing is fine). I'm writing a library that provides additional functionality to docker-py, which provides the docker
package, so you just import docker
and then you get access to docker.Client
etc.
Because it seemed a logical naming scheme, I wanted users to pull in my project with import docker.mymodule
, so I've created a directory called docker
with an __init__.py
, and mymodule.py
inside it.
When I try to access docker.Client
, Python can't see it, as if my docker
package has hidden it:
import docker
import docker.mymodule
docker.Client() # AttributeError: 'module' object has no attribute 'Client'
Is this possible, or do all top-level package names have to differ between source trees?