Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100468

Re: subclassing collections.Counter

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: subclassing collections.Counter
Date Tue, 15 Dec 2015 09:11:30 -0700
Lines 11
Message-ID <mailman.29.1450195938.22044.python-list@python.org> (permalink)
References <567036A5.6050205@gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de o3IbMOV7iDxnq9MH6nQlew9n7Cfd9LRPDdQWT95j4ZfQ==
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.022
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'received:209.85.223': 0.03; 'subject:skip:c 10': 0.07; 'metrics': 0.09; 'keys.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'attribute': 0.18; '2015': 0.20; 'class,': 0.22; 'maintains': 0.22; 'am,': 0.23; 'leave': 0.23; 'dec': 0.23; 'header:In-Reply- To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'values': 0.28; 'thus,': 0.29; '15,': 0.30; 'extend': 0.31; 'class': 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'returning': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'thought': 0.37; 'received:209': 0.38; 'hi,': 0.38; 'to:addr:python.org': 0.40; 'some': 0.40; 'sum': 0.69; 'to:name:python': 0.84; 'average.': 0.91; 'average': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=kMSiQoxeEUOL8ECC/PZa9exnNiF7MDB2ujWNukb0gC4=; b=Bx+YpyHTiLmOq/DhIv/FS7cFrwOr//Au2l7Wc12D6TehO0o88z/kaZpKE8K6JCIqyt 4RQUtgbCUWDdKgNZ4ltXvrbABviBLLGHFqSUv//lMB8wllZBwqM+gnGIGSGDpS3hgUS7 KmKBc6msqUt08sHxKOss0+bElkKThsxMFQdJgzhrha76sGIAwQ/S3p7p7VLHkR9R/pH9 GaX8TQYKa9GxaJ3rLasEGHfH1+LyLLkNKu53Xzy8iYNHJs43JBbh5N0HC8VLSSqAvuqs EmHS6f2jAxgMji3mtU2ukrHYmvyfvztQWYQJE7XZWSBlVXF2WCoAIYlQ+X7htzMjYU9+ KcyA==
X-Received by 10.107.19.30 with SMTP id b30mr7567075ioj.11.1450195930138; Tue, 15 Dec 2015 08:12:10 -0800 (PST)
In-Reply-To <567036A5.6050205@gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:100468

Show key headers only | View raw


On Tue, Dec 15, 2015 at 8:49 AM, Pavlos Parissis
<pavlos.parissis@gmail.com> 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 what it's designed for. Write
a custom Metrics class, with each attribute being a pseudo-collection
that maintains a sum or average.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: subclassing collections.Counter Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-15 09:11 -0700

csiph-web