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

2014-06-30 Thread Chris Angelico
On Tue, Jul 1, 2014 at 2:47 AM, 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 point

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

2014-06-30 Thread python
Ethan, >> Is this specific to the native Dict class (because its implemented in C vs. >> Python?) or is this behavior more general. > I /think/ it's only dict, but I haven't played with subclassing lists, > tuples, etc. It's not a C vs Python issue, but a 'implemented with __private methods'

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

2014-06-30 Thread Ethan Furman
On 06/30/2014 09:47 AM, pyt...@bdurham.com wrote: Keep in mind that dict /will not/ call your overridden methods, so if, for example, you provide your own __getitem__ you will also need to provide your own copies of any dict method that calls __getitem__. I'm not sure I understand. Are you say

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

2014-06-30 Thread python
Ethan, > Keep in mind that dict /will not/ call your overridden methods, so if, for > example, you provide your own __getitem__ you will also need to provide your own copies of any dict method that calls __getitem__. I'm not sure I understand. Are you saying that Chris's __getitem__ will not be

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

2014-06-30 Thread Ethan Furman
On 06/30/2014 07:44 AM, pyt...@bdurham.com wrote: Nice!!! I need to study your solution, but at first blush it looks exactly like what I wanted to implement. Keep in mind that dict /will not/ call your overridden methods, so if, for example, you provide your own __getitem__ you will also nee

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

2014-06-30 Thread python
Hi Chris, > Sounds like you want to subclass dict, then. Something like this: Nice!!! I need to study your solution, but at first blush it looks exactly like what I wanted to implement. Thank you! Malcolm -- https://mail.python.org/mailman/listinfo/python-list

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

2014-06-30 Thread Chris Angelico
On Mon, Jun 30, 2014 at 11:43 PM, wrote: > 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 in

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

2014-06-30 Thread python
n.org Subject: Creating a dict-like class that counts successful and failed key matches Date: Mon, 30 Jun 2014 09:43:49 -0400 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 ret

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

2014-06-30 Thread python
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