Advice Criticism on Python App
Tim Roberts
timr at probo.com
Fri Mar 26 23:15:27 EDT 2010
Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> wrote:
>On Wed, 24 Mar 2010 21:14:23 -0700, Tim Roberts wrote:
>
>> Jimbo <nilly16 at 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, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list