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


Groups > comp.lang.python > #73747

Creating a dict-like class that counts successful and failed key matches

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@bdurham.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'matches': 0.07; 'modified': 0.07; 'tool,': 0.07; 'key.': 0.09; 'keys,': 0.09; 'methods,': 0.09; 'override': 0.09; 'received:internal': 0.09; 'count,': 0.16; 'diagnostic': 0.16; 'dict': 0.16; 'from:addr:python': 0.16; 'goal,': 0.16; 'magic': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'processes.': 0.16; 'raised.': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.44': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:compute4.internal': 0.16; 'received:messagingengine.com': 0.16; 'retrieving': 0.16; 'subclass': 0.16; 'subject:class': 0.16; 'subject:failed': 0.16; 'subject:key': 0.16; 'exception': 0.16; 'basically': 0.19; 'subject:like': 0.24; 'returned': 0.30; "i'm": 0.30; 'code': 0.31; 'keys': 0.31; 'subject:that': 0.31; 'class': 0.32; 'covered': 0.32; 'regular': 0.32; "we're": 0.32; 'sense': 0.34; "i'd": 0.34; 'received:66': 0.35; 'common': 0.35; 'beyond': 0.35; 'curious': 0.36; 'should': 0.36; 'received:10': 0.37; 'implement': 0.38; 'thank': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'from:no real name:2**0': 0.61; 'tracking': 0.61; 'header:Message-Id:1': 0.63; 'high': 0.63; 'offering': 0.63; 'our': 0.64; 'provide': 0.64; 'total': 0.65; 'hints': 0.68; 'default': 0.69; 'counts': 0.83; 'dict,': 0.84; 'items,': 0.91
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=bdurham.com; h= message-id:from:to:mime-version:content-transfer-encoding :content-type:subject:date; s=mesmtp; bh=SHwj5ct9QHMKLLBa3yI7Mkq A+Nk=; b=F++2dO0k4IhDHzrHNFXJl2sM6u0OwgOBATJAV+DxI5Tygp9FQVtiTLH jL3AeVQolcJWIf/tb8uxlK16yMdRszpIH9LBNuHUwZL3aQzu6hk1lRMIqn7T7R46 JGD/eV9yMV8BhZXjklRRxR/SSVLHHPpDTl5AMsZcCKn6d+P39ih8=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:subject:date; s=smtpout; bh=SHwj5ct9QHMKLLBa3yI7MkqA+Nk=; b=oJvTgjKkJO57na3EChDouuO5yH+r 9/Z4kxWK8pCUFQURkJ8zT3T3qPl8ffDo++nIed/MDa/SkabwLKEXUaMYtspFMUYR T229YvBLlsP32UkSW1ZyjuoVpd420eVwMP0/V3VNmBS74MiO4uay3Mxxv+zdwgbD 6q9dGEagPsvRG4U=
X-Sasl-Enc MTZ+Gvo2B+yhA+8TITWfbD0h8+p+yVWAQmuyfSIllXtE 1404135829
From python@bdurham.com
To python-list@python.org
MIME-Version 1.0
Content-Transfer-Encoding 7bit
Content-Type multipart/alternative; boundary="_----------=_1404135829104853"; charset="utf-8"
X-Mailer MessagingEngine.com Webmail Interface - ajax-988f1f18
Subject Creating a dict-like class that counts successful and failed key matches
Date Mon, 30 Jun 2014 09:43:49 -0400
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.11342.1404135832.18130.python-list@python.org> (permalink)
Lines 57
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1404135832 news.xs4all.nl 2885 [2001:888:2000:d::a6]:34779
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73747

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

As a diagnostic tool, I would like to create a dict-like class
that counts successful and failed key matches by key. By failed
I mean in the sense that a default value was returned vs. an
exception raised. By count, I mean by tracking counts for
individual keys vs. just total success/failure counts. The
class needs to support setting values, retrieving values, and
retrieving keys, items, and key/item pairs. Basically anything
that a regular dict, I'd like my modified class to do as well.
Use case: I'm curious to see what key's we're missing that our
code is using default to provide and I'm also interested in
looking at our high frequency keys as a way to double check our
processes.
Is this a common pattern covered by the standard lib (I don't
see anything in collections)?
I'm looking for ideas on how to implement ... as a subclass of
Dict, as a duck-like class offering Dict like methods, other?
I'm also looking for some hints on what magic methods I should
override to accomplish my goal, eg. beyond __getitem__.
Thank you,
Malcolm

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


Thread

Creating a dict-like class that counts successful and failed key matches python@bdurham.com - 2014-06-30 09:43 -0400

csiph-web