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

Chris Angelico rosuav at gmail.com
Tue Jul 1 00:08:27 CEST 2014


On Tue, Jul 1, 2014 at 2:47 AM,  <python at 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



More information about the Python-list mailing list