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


Groups > comp.lang.python > #73765

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

References <1404135829.10485.136092537.2F0486D2@webmail.messagingengine.com> <CAPTjJmpkz4DPyCYSPNoteUuuBOzySzhjHzYPEXUv4MFH1sYE1A@mail.gmail.com> <1404139465.27658.136120269.0CA38211@webmail.messagingengine.com> <53B18398.4090302@stoneleaf.us> <1404146834.28955.136173757.51576D44@webmail.messagingengine.com>
Date 2014-07-01 08:08 +1000
Subject Re: Creating a dict-like class that counts successful and failed key matches
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.11353.1404166116.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Jul 1, 2014 at 2:47 AM,  <python@bdurham.com> wrote:
> I'm not sure I understand. Are you saying that Chris's __getitem__ will
> not be called by other dict methods that would normally call this magic
> method and instead call the parent's __getitem__ directly (via super()
> or something similar?)?

He's pointing out the general principle behind what I said about the
.get() method; if you don't override .get() with your own
implementation, it won't pass the request through your __getitem__, so
it won't be statistically analyzed. That might be a good thing; it
means you're going to have to be explicit about what gets counted.

ChrisA

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


Thread

Re: Creating a dict-like class that counts successful and failed key matches Chris Angelico <rosuav@gmail.com> - 2014-07-01 08:08 +1000

csiph-web