Kottiyath wrote:
So, in a higher level class, have a weakref list which contains a
reference to each person. Total count will be len(list) at any time.
Now, I couldnt find a weakref list - so I am using WeakKeyDictionary
with the value as None - since len(dict) also should give me the data
I ty
Thank you everyone for your very helpful comments and suggestions. I
have interacted in other newsgroups, but this is the most helpful of
them all.
As per the comments, I have now decided to go with the weakref
mechanism - as per Andreas suggestion, functionally it looks correct
that the person sh
Mark Wooding wrote:
> Andreas Waldenburger writes:
>
>> On Sun, 25 Jan 2009 09:23:35 -0800 (PST) Kottiyath
>> wrote:
>>
>>> class a(object):
>>> counter = 0
>>> def __new__(cls, *args, **kwargs):
>>> a.counter += 1
>>> return object.__new__(cls, *args, **kwargs)
>
> Hmm.
On Mon, 26 Jan 2009 02:37:37 + Mark Wooding
wrote:
> > This looks OK, although I'd suggest using "cls.counter += 1" instead
> > of "a.counter += 1" in the __new__() method. Just seems clearer to
> > me, esp. when you think about subclassing.
>
> I'm not sure about clarity, but that would be
Andreas Waldenburger writes:
> On Sun, 25 Jan 2009 09:23:35 -0800 (PST) Kottiyath
> wrote:
>
>> class a(object):
>> counter = 0
>> def __new__(cls, *args, **kwargs):
>> a.counter += 1
>> return object.__new__(cls, *args, **kwargs)
Hmm. Exceptions raised during object cr
En Sun, 25 Jan 2009 16:06:47 -0200, Andreas Waldenburger
escribió:
On Sun, 25 Jan 2009 09:23:35 -0800 (PST) Kottiyath
wrote:
I am creating a class called people - subclasses men, women, children
etc.
I want to count the number of people at any time.
So, I created code like the following:
En Sun, 25 Jan 2009 16:06:47 -0200, Andreas Waldenburger
escribió:
On Sun, 25 Jan 2009 09:23:35 -0800 (PST) Kottiyath
wrote:
I am creating a class called people - subclasses men, women, children
etc.
I want to count the number of people at any time.
So, I created code like the following:
On Sun, 25 Jan 2009 09:23:35 -0800 (PST) Kottiyath
wrote:
> Hi,
> I am creating a class called people - subclasses men, women, children
> etc.
> I want to count the number of people at any time.
> So, I created code like the following:
>
> class a(object):
> counter = 0
> def __new__(cls
Kottiyath wrote:
> Hi,
> I am creating a class called people - subclasses men, women, children
> etc.
> I want to count the number of people at any time.
> So, I created code like the following:
>
> class a(object):
> counter = 0
> def __new__(cls, *args, **kwargs):
> a.counter +=
Hi,
I am creating a class called people - subclasses men, women, children
etc.
I want to count the number of people at any time.
So, I created code like the following:
class a(object):
counter = 0
def __new__(cls, *args, **kwargs):
a.counter += 1
return object.__new__(cls,
10 matches
Mail list logo