Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100471
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Pavlos Parissis <pavlos.parissis@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: subclassing collections.Counter |
| Date | Tue, 15 Dec 2015 17:20:56 +0100 |
| Lines | 50 |
| Message-ID | <mailman.31.1450196467.22044.python-list@python.org> (permalink) |
| References | <567036A5.6050205@gmail.com> <CALwzidnifp20WayShDXTGJ-PxdCk0LeZVb-o9fTQzFCN6i1dUQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HoQsqMS4xPD9oSwvdDifoGD49bmPv2Dwj" |
| X-Trace | news.uni-berlin.de NLHTvqUUSBQ0SfX0xfTaSwipa0gNBy5/Y0gSMTnz7EwA== |
| Return-Path | <pavlos.parissis@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'override': 0.07; 'subject:skip:c 10': 0.07; 'methods,': 0.09; 'metrics': 0.09; 'filename:fname piece:signature': 0.16; 'keys.': 0.16; 'magic': 0.16; 'received:192.168.0.103': 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; 'cheers,': 0.22; 'am,': 0.23; 'leave': 0.23; 'dec': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'values': 0.28; 'extending': 0.29; 'thus,': 0.29; '15,': 0.30; 'extend': 0.31; 'class': 0.33; 'problem': 0.33; 'right?': 0.33; 'message-id:@gmail.com': 0.34; 'tue,': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'returning': 0.35; 'received:74.125.82': 0.35; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'thought': 0.37; 'hi,': 0.38; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'real': 0.62; 'sum': 0.69; 'average.': 0.91; 'average': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=0eeozCDmDi/Mycw8e7ZR0/MYjkM/feX39t//UnSavwk=; b=qQdxftzG+6QxNNBytr645eS/18RDV5v1en7sNcuBx7CUI1lPaJKsdrbW1oIYOV7IID bsGcVr8UC8W8Zj2wfTgnx6oemVdOu80xPIJRypvkIJg7PpUh0nYwu9/OyVTRRFi9rsZm zTqVHZSQFv0fskBteDRtG/NgHvXy44tGgp6PIF43H7gXC1UJllJj/u9U4lNfHogV+oFh 4q3c08UFKq1K4nwpf0oQWCZt9GcF4vlnXoQasW0GP8PTGmZEvjWTQfhNRMI6/OBjIjuy D/mZu6BV42MS/D2AMKy1SMsOHilEZQoSgIcXVogrIRRmprpytgpboXNzf8xq8lPBI0hY sn9A== |
| X-Received | by 10.28.87.131 with SMTP id l125mr1538320wmb.8.1450196459327; Tue, 15 Dec 2015 08:20:59 -0800 (PST) |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 |
| In-Reply-To | <CALwzidnifp20WayShDXTGJ-PxdCk0LeZVb-o9fTQzFCN6i1dUQ@mail.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:100471 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 15/12/2015 05:11 μμ, Ian Kelly wrote: > 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. > But then I will have to override a lot of magic methods, right? What is the real problem of extending Counter in the way I did? Cheers, Pavlos
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: subclassing collections.Counter Pavlos Parissis <pavlos.parissis@gmail.com> - 2015-12-15 17:20 +0100
csiph-web