On May 9, 5:49 pm, [EMAIL PROTECTED] wrote:
> Thanks for the insights. I solved the problem as follows: I created a
> new class method called cleanUp, which resets NStocks to an empty list
> and N1 to 0. Works like a charm - it's the first time I've used a
> class method, and I immediately see its
Thanks for the insights. I solved the problem as follows: I created a
new class method called cleanUp, which resets NStocks to an empty list
and N1 to 0. Works like a charm - it's the first time I've used a
class method, and I immediately see its utility. Thanks again
class Stock(object):
NSto
On May 9, 5:25 pm, [EMAIL PROTECTED] 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
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| Here's what I expect to happen each time simulation( ) is called: the
| class variable NStocks for the class Stock is initialized to an empty
| list,
Why would you expect that ;-)
A class statement is usually executed exactly once, as
To test some theories, I created a new class variable, an int named
N1, which is not mutable. So my Stock class now looks as follows:
class Stock(object):
NStocks = [] #Class variables
N1 = 0
def __init__(self, id, returnHistory):
self.id = id
self
[EMAIL PROTECTED] schrieb:
> I have written a program that runs portfolio simulations with
> different parameters and prints the output, but am mystified by the
> behavior of a mutable class variable. A simplified version of the
> program follows - would you kindly help me understand why it behaves
I have written a program that runs portfolio simulations with
different parameters and prints the output, but am mystified by the
behavior of a mutable class variable. A simplified version of the
program follows - would you kindly help me understand why it behaves
the way it does.
The function mai