Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: subclassing collections.Counter Date: Tue, 15 Dec 2015 09:11:30 -0700 Lines: 11 Message-ID: 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100468 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 what it's designed for. Write a custom Metrics class, with each attribute being a pseudo-collection that maintains a sum or average.