Mapping, with sequence as key, wildcard and subsequence matching

Ben Finney ben+python at benfinney.id.au
Thu Jul 16 01:55:15 EDT 2015


Terry Reedy <tjreedy at udel.edu> writes:

> On 7/15/2015 9:51 PM, Ben Finney wrote:
> > What well-defined data type exists with the following properties:
> >
> > * Mapping, key → value.
> >
> > * Each key is a sequence (e.g. `tuple`) of items such as text strings.
> >
> > * Items in a key may be the sentinel `ANY` value, which will match any
> >    value at that position.
> >
> > * A key may specify that it will match *only* sequences of the same
> >    length.
> >
> > * A key may specify that it will match sequences with arbitrarily many
> >    additional unspecified items.
>
> Every key should signal which of the last two alterntives holds. One
> can be a default.  The signal can be 'in-band', in the tuple key
> itself, or 'out-of-band', not in the tuple key.

Thanks. The part which puzzle me though: How do we teach the mapping
type about that matching behaviour?

-- 
 \            “Without cultural sanction, most or all of our religious |
  `\          beliefs and rituals would fall into the domain of mental |
_o__)                                 disturbance.” —John F. Schumaker |
Ben Finney




More information about the Python-list mailing list