Re: subclassing collections.Counter

2015-12-15 Thread Pavlos Parissis
On 15/12/2015 06:55 μμ, Ian Kelly wrote: > On Tue, Dec 15, 2015 at 10:43 AM, Pavlos Parissis > wrote: >>> If you want your metrics container to act like a dict, then my >>> suggestion would be to just use a dict, with pseudo-collections for >>> the values as above. >>> >> >> If I understood you co

Re: subclassing collections.Counter

2015-12-15 Thread Ian Kelly
On Tue, Dec 15, 2015 at 10:43 AM, Pavlos Parissis wrote: >> If you want your metrics container to act like a dict, then my >> suggestion would be to just use a dict, with pseudo-collections for >> the values as above. >> > > If I understood you correctly, you are saying store all metrics in a > di

Re: subclassing collections.Counter

2015-12-15 Thread Pavlos Parissis
On 15/12/2015 06:22 μμ, Ian Kelly wrote: > On Tue, Dec 15, 2015 at 9:20 AM, Pavlos Parissis > wrote: >> On 15/12/2015 05:11 μμ, Ian Kelly wrote: >>> On Tue, Dec 15, 2015 at 8:49 AM, Pavlos Parissis >>> wrote: Hi, I need to store values for metrics and return the average for some >>

Re: subclassing collections.Counter

2015-12-15 Thread Ian Kelly
On Tue, Dec 15, 2015 at 9:20 AM, Pavlos Parissis wrote: > On 15/12/2015 05:11 μμ, Ian Kelly wrote: >> On Tue, Dec 15, 2015 at 8:49 AM, Pavlos Parissis >> wrote: >>> Hi, >>> >>> I need to store values for metrics and return the average for some >>> and the sum for the rest. Thus, I thought I could

Re: subclassing collections.Counter

2015-12-15 Thread Pavlos Parissis
On 15/12/2015 05:18 μμ, Pavlos Parissis wrote: > On 15/12/2015 05:08 μμ, Peter Otten wrote: >> Pavlos Parissis wrote: >> >>> I need to store values for metrics and return the average for some >>> and the sum for the rest. Thus, I thought I could extend >>> collections.Counter class by returning ave

Re: subclassing collections.Counter

2015-12-15 Thread Pavlos Parissis
On 15/12/2015 05:11 μμ, Ian Kelly wrote: > On Tue, Dec 15, 2015 at 8:49 AM, Pavlos Parissis > wrote: >> Hi, >> >> I need to store values for metrics and return the average for some >> and the sum for the rest. Thus, I thought I could extend >> collections.Counter class by returning averages for so

Re: subclassing collections.Counter

2015-12-15 Thread Ian Kelly
On Tue, Dec 15, 2015 at 8:49 AM, Pavlos Parissis wrote: > Hi, > > I need to store values for metrics and return the average for some > and the sum for the rest. Thus, I thought I could extend > collections.Counter class by returning averages for some keys. Leave Counter out of it, as this is not

Re: subclassing collections.Counter

2015-12-15 Thread Pavlos Parissis
On 15/12/2015 05:08 μμ, Peter Otten wrote: > Pavlos Parissis wrote: > >> I need to store values for metrics and return the average for some >> and the sum for the rest. Thus, I thought I could extend >> collections.Counter class by returning averages for some keys. >> >> My class modifies the upda

Re: subclassing collections.Counter

2015-12-15 Thread Peter Otten
Pavlos Parissis wrote: > I need to store values for metrics and return the average for some > and the sum for the rest. Thus, I thought I could extend > collections.Counter class by returning averages for some keys. > > My class modifies the update() to increment a counter and the > __getitem__ t

subclassing collections.Counter

2015-12-15 Thread Pavlos Parissis
Hi, I need to store values for metrics and return the average for some and the sum for the rest. Thus, I thought I could extend collections.Counter class by returning averages for some keys. My class modifies the update() to increment a counter and the __getitem__ to perform the calculation. But,