Everything you said is absolutely correct. I was being lazy. I had a main program in module, and wanted to reorganize it, putting most of it into a new module. Being python, it actually only took a small effort to fix this properly, so that in B.py, what were global variables are now passed as arguments to class constructors and functions.
Still curious about the answer. If I know that I am imported from __main__, then I can do access X as sys.modules[__main__].X. In general, I don't know how to determine who is importing me. -- http://mail.python.org/mailman/listinfo/python-list