Bugs item #1453145, was opened at 2006-03-18 16:32
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1453145&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Ali Gholami Rudi (aligrudi)
Assigned to: Nobody/Anonymous (nobody)
Summary: Unexpected module reloading
Initial Comment:
I'll demonstrate the problem:
Consider the following package hierarchy:
p/
__all__.py
m1.py
m2.py
The contents of m1 and m2 modules are:
-----m1.py----
import m2
import p.m2
--------------
-----m2.py----
print 'Loading m2 module'
--------------
Running the m1 module would yield the output
Loading m2 module
Loading m2 module
. As it is obvious from the output the module m2 is
loaded twice. The problem arrises when you want to do
things such as implementing a singleton class:
-----Alternate m2.py-----
class Singleton(object):
_instance = None
@staticmethod
def getInstance():
if Singleton._instance is None:
Singleton._instance = Singleton()
return _instace
-------------------------
-----Alternate m1.py-----
import m2
import p.m2
print m2.Singleton.getInstance()
print p.m2.Singleton.getInstance()
-------------------------
If you run m1 module, the output shows that the two
instaces are not the same objects. That is m2.Singleton
and p.m2.Singleton are not the same classes.
I think this is a bug.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1453145&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com