Mapping, with sequence as key, wildcard and subsequence matching

Mark Lawrence breamoreboy at
Thu Jul 16 09:09:05 CEST 2015

On 16/07/2015 07:37, Ben Finney wrote:
> Ethan Furman <ethan at> writes:
>> On 07/15/2015 10:53 PM, Ben Finney wrote:
>>> Are those the ‘__contains__’, ‘__getitem__’ methods? What actually
>>> is the API of a mapping type, that would need to be customised for
>>> this application?
>> The problem is that potential key matches are found by hashes
> For the Python ‘dict’ type, yes. I already know that I don't want that
> type, I want a custom mapping type which matches keys according to the
> algorithm I specify.
> So, I'm not asking “how do I make ‘dict’ do this?”. I am instead asking
> “how do I implement a custom type which can duck-type for ‘dict’ but
> have a different key-lookup implementation?”.

The collections module provides a MutableMapping abstract base class to 
help create those methods from a base set of __getitem__(), 
__setitem__(), __delitem__(), and keys()


Hunting for examples got me to 
so fingers crossed, I'm just hoping that we're going in the right direction.

My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

More information about the Python-list mailing list