Steven D'Aprano <ste...@remove.this.cybersource.com.au> wrote:

>On Wed, 24 Mar 2010 21:14:23 -0700, Tim Roberts wrote:
>
>> Jimbo <nill...@yahoo.com> wrote:
>>>
>>>class stock:
>>>    code             = ""
>>>    purchasePrice    = 0
>>>    purchaseQuantity = 0
>>>    price            = []  # list of recent prices 
>>>    recentBid        = []  # list of recent bids for stock
>>>    recentOffer      = []  # list of recent offers for stock
>>>    stockVol         = []  # list of stock quantity available on market
>> 
>> Using lists as class variables is a very good way to create very
>> surprising bugs.  Consider the following:
>
>Don't you think that the class attributes are *supposed* to be shared by 
>all instances? In that case the behaviour you show is not a bug at all.

Yes, it occurred to me just after I sent that pot that I had answered a
different question from the one he asked.  I SUSPECT that he is using class
variables as a way to initialize members, not as true class variables.

Thanks for clarifying this.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to