Steven D'Aprano <[EMAIL PROTECTED]> writes: > I recall that Python guarantees that module objects are singletons, and > that this must hold for any implementation, not just CPython: you can > only ever create one instance of a module via the import mechanism. But > my google-foo is obviously weak today, I cannot find where the Python > language reference guarantees that. Can somebody please point me at the > link making that guarantee?
It's not an absolute strict guarantee; it's just implied by the fact that "import" uses any appropriate objects already found in sys.modules. >>> import sys >>> ll = [] >>> for i in range(2): ... import string ... ll.append(string) ... del sys.modules['string'] ... >>> ll[0] is ll[1] False (I'm sure there are very good reasons never to do what I just did there.) -- Micah J. Cowan Programmer, musician, typesetting enthusiast, gamer... http://micah.cowan.name/ -- http://mail.python.org/mailman/listinfo/python-list