I'm trying to create a module and it's worried that I might be doing something wrong. I'm encountering some problems with my namespace. I've made an example much like what I have, it has three files with file names according to the comments.
# $PYTHON_PATH/a/b.py class X: pass def make_x(): return X() and I have an init file
# $PYTHON_PATH/a/__init__.py from b import make_x Then I have a file
# $PYTHON_PATH/a/c.py from b import X x = X() # For testing if __name__ == "__main__": from a import * y = make_x() print x.__class__ print y.__class__ print isinstance(x,X) print isinstance(y,X) Output on running c.py
b.X a.b.X True False Perhaps this is just a problem with importing the module from within the module and will go away when I am not testing in this kind of hacky way (from a import *). Is this true, or is there something wrong with how I am structuring the whole thing.
python -m a.cin the parent directory of directorya.