Mapping, with sequence as key, wildcard and subsequence matching

Ben Finney ben+python at
Thu Jul 16 08:37:50 CEST 2015

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?”.

 \       “As the most participatory form of mass speech yet developed, |
  `\    the Internet deserves the highest protection from governmental |
_o__)                   intrusion.” —U.S. District Court Judge Dalzell |
Ben Finney

More information about the Python-list mailing list