Behavior of mutable class variables
tkpmep at hotmail.com
tkpmep at hotmail.com
Wed May 9 18:05:32 EDT 2007
On May 9, 5:25 pm, tkp... at hotmail.com wrote:
> To test some theories, I created a new class variable, an int named
Diez,
Thanks. It is for precisely this reason that I added another class
variable - the immutable int N1. But this too keeps getting
incremented on subsequent calls to simulation( ). I also tried setting
the class variable N1 to 0 at the end of the simulation and also
deleting all the stocks in port (see below). Nothing works - and I
don't understand why.
def simulation(N, par1, par2, idList, returnHistoryDir):
port = []
for i in range(N):
port.append( Stock(idList[i], returnHistoryDir[idList[i]] )
p[0].NStocks = 0
del port[:]
results = ......
print results.
More information about the Python-list
mailing list