$ ipy test.py 1 $ python test.py 2 File contents follow: note that doing "import y" instead of "__import__" changes the result. # test.py import x.y # x/__init__.py #empty # x/y.py a = 1 y = __import__('y') print y.a # y.py a = 2